tag:blogger.com,1999:blog-7271315367558300569.post4591658380945432459..comments2024-02-01T05:10:14.833-08:00Comments on The Unorthodox Engineers: Review: Arduino Motor Drivers - AdaFruit Motor Shield vs RepRap StepStickAnonymoushttp://www.blogger.com/profile/13912838690573000458noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7271315367558300569.post-27431053543912751132014-03-27T08:19:16.527-07:002014-03-27T08:19:16.527-07:00could you upload the .h and .cpp files?
Would be g...could you upload the .h and .cpp files?<br />Would be great :(Anonymoushttps://www.blogger.com/profile/14569744322270366057noreply@blogger.comtag:blogger.com,1999:blog-7271315367558300569.post-31382842543032577562014-01-28T22:53:01.557-08:002014-01-28T22:53:01.557-08:00/*
The base device class for dealing with the ada...<br />/*<br /> The base device class for dealing with the adafruit motor shield. Mostly this just<br /> sends a direction byte to the shift register - all the actual "motor control" depends<br /> on application. (Mostly using PWM, or the Motivator)<br /> */<br />class AdaMotorDevice {<br />protected:<br /> static const int PWM_0A = 6;<br /> static const int PWM_0B = 5;<br /> static const int PWM_1A = 9;<br /> static const int PWM_1B = 10;<br /> static const int PWM_2A = 11;<br /> static const int PWM_2B = 3;<br /> static const int DIR_EN = 7;<br /> static const int DIR_SDA = 8;<br /> static const int DIR_CLK = 4;<br /> static const int DIR_LATCH = 12;<br /> // latch bit mappings<br /> static const int LATCH_1A = 2;<br /> static const int LATCH_1B = 3;<br /> static const int LATCH_2A = 1;<br /> static const int LATCH_2B = 4;<br /> static const int LATCH_3A = 0;<br /> static const int LATCH_3B = 6;<br /> static const int LATCH_4A = 5;<br /> static const int LATCH_4B = 7;<br /> //<br /> byte _motor_forward[4];<br />public:<br /> // constructor<br /> AdaMotorDevice() {<br /> // since we have so many to do..<br /> int out[] = { LOW, HIGH, LOW, LOW, HIGH, HIGH, LOW, LOW, LOW, HIGH };<br /> for(int i=3; i<13; i++) {<br /> pinMode(i, OUTPUT); digitalWrite(i,out[i-3]);<br /> }<br /> // all motors start forward.<br /> memset(_motor_forward, 0x01, 4);<br /> update_direction();<br /> }<br /> // destructor<br /> ~AdaMotorDevice() {<br /> <br /> }<br /> void forward(byte motor) {<br /> if(motor<4) _motor_forward[motor] = 1;<br /> }<br /> void reverse(byte motor) {<br /> if(motor<4) _motor_forward[motor] = 0; <br /> }<br /> void exec() {<br /> update_direction();<br /> }<br />private:<br /> // update the motor shield with the latest direction information<br /> void update_direction() {<br /> // rebuild the direction byte<br /> byte d = 0;<br /> d |= _motor_forward[0] ? (1<<LATCH_1A) : (1<<LATCH_1B);<br /> d |= _motor_forward[1] ? (1<<LATCH_2A) : (1<<LATCH_2B);<br /> d |= _motor_forward[2] ? (1<<LATCH_3A) : (1<<LATCH_3B);<br /> d |= _motor_forward[3] ? (1<<LATCH_4A) : (1<<LATCH_4B);<br /> // send the update<br /> send_direction(d);<br /> }<br /> <br /> // send direction byte to motorshield shift register<br /> void send_direction(byte dir) {<br /> // enable the shift register<br /> // digitalWrite(DIR_EN, HIGH);<br /> // release the latch before transfer<br /> digitalWrite(DIR_LATCH, LOW);<br /> // and start clocking out the bits<br /> shiftOut(DIR_SDA, DIR_CLK, MSBFIRST, dir);<br /> // and set the latch<br /> digitalWrite(DIR_LATCH, HIGH); <br /> // this should always be low, but take a moment to be sure<br /> digitalWrite(DIR_EN, LOW);<br /> }<br />};<br />Anonymoushttps://www.blogger.com/profile/13912838690573000458noreply@blogger.comtag:blogger.com,1999:blog-7271315367558300569.post-15588342263819497012014-01-25T00:19:13.598-08:002014-01-25T00:19:13.598-08:00I need the code for the leonardo compatible motors...I need the code for the leonardo compatible motorshield lib!!! big thx!Anonymoushttps://www.blogger.com/profile/12052125958441759152noreply@blogger.comtag:blogger.com,1999:blog-7271315367558300569.post-37710833487970078172014-01-24T01:47:10.280-08:002014-01-24T01:47:10.280-08:00the adapted motorshield libary would be nice to ha...the adapted motorshield libary would be nice to have. thxAnonymoushttps://www.blogger.com/profile/12052125958441759152noreply@blogger.comtag:blogger.com,1999:blog-7271315367558300569.post-43929348286990356542014-01-24T01:45:20.884-08:002014-01-24T01:45:20.884-08:00could you please send me the motorshield working w...could you please send me the motorshield working with leonardo boards. thxAnonymoushttps://www.blogger.com/profile/12052125958441759152noreply@blogger.com