CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

need help with 18f4431 to move motor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








need help with 18f4431 to move motor
PostPosted: Sun Mar 15, 2009 2:12 pm     Reply with quote

I tried to rotate my motor with external input button. what I need to do is to let motor rotate, say 1000.1 turns with button one, 2000.5 turns with button 2, 3000.7 turns with button3 and so on. To save time, all required the motor increase speed to max then keep at max speed running for seconds, and decrease speed to zero when it rotate to require turns.


I think I need to use QEI. But after reading data sheet and search on line, I found that QEI should be used to monitoring or measuring the position or speed of my motor; some said that I may need to use additional input channel instead of QEI to fulfill my goal, and I may need another input channel as homing for motor to return to its home position for better precise position control.

I get lost. Any one can give me some suggestion?

thanks
Ttelmah
Guest







PostPosted: Sun Mar 15, 2009 3:16 pm     Reply with quote

There are several parts to this.
The comment about having an extra 'home' input, is correct, if the code needs to be able to go to 'absolute' positions.
Then, what you need to implement, is a PID servo. There are examples for this in the Microchip examples. Most without QEI (which simplifies the actual implementation of counting the quadrature encoder pulses). The QEI part is the simplest bit though. I have posted significant parts of a CCS servo implementation in the past here. The exact implementation details, will depend on the speed of your motor, how many pulses per rev, your encoders generate, the inertia of the hardware, etc..
Once you have this implemented, you then add simple code to specify the target for the movement, based on button inputs.
Now undertand, this is not a five minute project, and because it will need significant tweaking for your hardware, most will have to be custom written by you. You are not going to be able to pick up 'off the shelf' code to do this.
You should start by simply implementing the QEI component. Then, with the data from this, look at servo examples, and see if you can work out how to attach these together. Then, probably simpler to experiment, using RS232, to send a position from the serial, and see if you can get the algoritm to correctly move as required. Finally build your button interface.
If the code is to give accurate positions, you will need a reasonable number of pulses per rev from the encoder. This also helps in allowing the servo update rate to be faster, with a reasonable number of counts between updates. Keeping the update rate high, will involve careful coding of the arithmetic (my examples used scaled integer arithmetic, carefully chosen to give a fast rate within the number scale of results wanted).

Best Wishes
x7r



Joined: 15 Mar 2009
Posts: 1

View user's profile Send private message

PostPosted: Mon Mar 16, 2009 8:30 am     Reply with quote

great help! You are super nice to lead me to the right direction. I got lost at the start when I pick up this project, even no idea where I should start with.

Thanks again and I think I should do as you said to work with a RS232 to move the motor first then use the PID and then add more. Otherwise, I think I will lost again if I want to make a big cake as a beginner.

All my Best!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group