arduino dc motor driver l298 h-bridge arduino gui vs atmel studio stefan pirvu adces 2015

12
Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

Upload: russell-blake

Post on 21-Dec-2015

257 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

Arduino DC motor driverL298 H-Bridge

Arduino GUI vs Atmel Studio

Stefan PirvuADCES 2015

Page 2: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

Content

• Arduino board review• Serial communication, writing C# app in order

to communicate over serial - code• Using H-Bridge to power DC motors• PWM vs. continuous voltage drive• Arduino GUI - code• Atmel Studio - code

Page 3: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

Arduino board review

• USB support• 16MHz• 32k memory• 14 I/O pins• 5 PWM pins• 6 ADC pins

Page 4: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

Using H-Bridge to power DC motors

Page 5: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

L298

• http://www.tech.dmu.ac.uk/~mgongora/Resources/L298N.pdf

• Cheap aprox. 10-20 RON• Dual H-Bridge

Page 6: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

PWM vs. continuous voltage drive

Analog• bad at low voltages• needs mechanical switches• ranges depend on the

number of resistors• very resistant over time

Digital• good at low voltages• fine control • buzz sounds

Page 7: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

Arduino GUI

• http://arduino.cc/• Serial communication, writing C# app in order

to communicate over serial

• CODE

Page 9: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

AIN0/OC0A/PCINT22 – Port D, Bit 6OC0A, Output Compare Match output: The PD6 pin can serve as an external output for the Timer/Counter0. Compare Match A. The PD6 pin has to be configured as an output (DDD6 set (one)) to serve this function. The OC0A pin is also the output pin for the PWM mode timer function.

T1/OC0B/PCINT21 – Port D, Bit 5OC0B, Output Compare Match output: The PD5 pin can serve as an external output for the Timer/Counter0. Compare Match B. The PD5 pin has to be configured as an output (DDD5 set (one)) to serve this function. The OC0B pin is also the output pin for the PWM mode timer function.

ATMEGA328P

Page 10: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

ATMEGA328 Timer/Counter

• LET’S CODE

Timer Registers Several registers are used to control each timer. The Timer/Counter Control Registers TCCRnA and TCCRnB hold the main control bits for the timer. (Note that TCCRnA and TCCRnB do not correspond to the outputs A and B.) These registers hold several groups of bits: Waveform Generation Mode bits (WGM): these control the overall mode of the timer. (These bits are split between TCCRnA and TCCRnB.) Clock Select bits (CS): these control the clock prescaler Compare Match Output A Mode bits (COMnA): these enable/disable/invert output A Compare Match Output B Mode bits (COMnB): these enable/disable/invert output B

Page 11: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

Use AVRDude to upload HEX

• >C:\Program Files\Arduino\hardware\tools\avr\bin

• avrdude.exe -C”C:Program Files\Arduino\hardware\tools\avr\etc\avrdude.conf” f -patmega328p -carduino -P\.COM4 -b115200 -D -Uflash:w:”$(ProjectDir)Debug$(TargetName).hex”:i

Page 12: Arduino DC motor driver L298 H-Bridge Arduino GUI vs Atmel Studio Stefan Pirvu ADCES 2015

Thank you

• QUESTIONS??