go_away

Author Topic: motor control written in c language with pic mcu advice  (Read 1448 times)

0 Members and 1 Guest are viewing this topic.

Offline robo007Topic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
motor control written in c language with pic mcu advice
« on: March 22, 2012, 10:14:03 PM »
any good links or books on programming in c language for robotics i have 10 books on robotics, but is there anything especially on motor control? or any links, sum1 should seriously write a book on c language and motor control, they mite make sum money from me and others like me getting started, im using a pic 16f690 but if i need more pins ill step it up, my project consists of a microcontroller to a driver ic or 2 driver ics like the l298 to power 4 of the smallest cheapest dc motors money can buy, with two rotary switches, with 12 to 16 modes on each, an on off switch, a potentiometer switch, for speed and a forward and reverse switch unless i can have a special miniature switch customized where its at 0 in the middle and can go forward and reverse with speed adjustment in either direction directly from the switch, kinda like a switch on a keyboard piano, but that starts in the center, its a slider switch, I need to get this robot done, rite now im going off the robot builders cook book, and the questar robot schematic, its similar to my project accept that it uses an old fashiond h bridge, instead of a driver ic, uses less modes, only uses 1 rotary switch, doesnt use a potentiometer, and thats where im starting from. I also will be varying by using c language and  hes using basic, any help on this would be great thanks

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: motor control written in c language with pic mcu advice
« Reply #1 on: March 23, 2012, 02:56:35 AM »
Wow, all that in three sentences ;D

Motor control is not that difficult. Just find info online regarding Timers and PWM.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline LargoLobo

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: motor control written in c language with pic mcu advice
« Reply #2 on: March 24, 2012, 12:16:22 PM »
Using the Arduino board, it has a subset of the C-language, which is easy to program for motor control. PWM for servos the easiest, but if you want to control Unipolar and Bipolar stepper motors, the code is more complex and is hardware dependent. I started with Bipolar motors first and used the L298 chip (dual H-switches). That works, but the currents are high and the resultant heat in the chip is of concern. I add the L297 and associated passive parts to my breadboard and found this systematic approach to control the current in the coil via sensing from the L298 and to the L297 worked very well and I set the holding current down to 100ma verse over an amp without the control. The motor voltage can be increased over rated for a quick and strong stepping. The circuit is found on the datasheets for the parts. I used an L6210 dual schottky bridge of high speed diodes for flyback protection. Now the Arduino only has to provide direction and step count.

For Unipolar steppers I build a breadboard using four IRF530 MOSFET with 1N4004 diode protection to drive the coils of the motor. The trick here is identifing the coil halves. For example, coil A would be A1 and A2 with the center tap going to motor supply. The same for coil B, but the firing sequence is A1, B1, A2, B2 to get the motor to run smoothly. This is a trial and error approach because the motor maker don't label the wiring. Now you need a four bit sequence where one High bit progresses along with the other three a Low. The TTL output will turn on the FET, but don't add an LED or the like or the FET won't fire. To get the sequence, I used a 74LS194 bidirectional 4-bit shift register. It matched the requirements perfectly, but everything is handled in the software.

Use asked about the software: If you use the timing diagram from the datasheet of the 74LS194 and create a signal for each pin and just write the clock Low then High and back to Low you create a clock cycle in software. Place the other signal to go High and then Low in relationship to the clock sequence in code the chip behaves perfectly. I used shift left to for CW and shift right or CCW and start the sequence by injecting a High with the pins provided. The steps are continued with software clock cycles with the noteworthy trick that you have reintroduce the pulse every four cycles which requires using the modulo math operator.

I plan to have a YouTube video on my designs and software soon. I'll post again when that's up. My next challenge is control DC motor better than on and off. I want to control the acceleration and provide a feedback to control position like the way Hp does in their printers by reading a film strip of tiny lines with an optical sensor.

Good luck with you efforts - LargoLobo

Offline joe61

  • Supreme Robot
  • *****
  • Posts: 417
  • Helpful? 16
Re: motor control written in c language with pic mcu advice
« Reply #3 on: March 24, 2012, 12:40:23 PM »
any good links or books on programming in c language for robotics [...]

If you google "pic motor control" you'll find some. If you google "pic tutorial" you'll find some of those too.

Joe

 


Get Your Ad Here

data_list