Hi Guys
This is my first post and very much fascinated by this forum. You people are just great. I am working on my project "Inverted Pendulum on a Cart" and have just started pulling up my hairs. I am using PIC 16F877A with 20MHz crystal and assembly language. I got following few questions.
1) The result generated by A2D from my angle measurement potentiometer is 10bit (NumH & NumL). I am doing left justified and igonoring the register NumL to make it 8bit to make it simple to deal with.
Then I subtract it from my reference signal which is zero which gives me error signal which is a signed number.
Then I need to multiply this error signal with proportional value which is unsigned number (Please note I am ignorinng Integral and derivative term at the moment).
What command can I use to make proportional value a signed number as I suppose we can multiply signed number by signed number only. Can anyone please recomend any good routine for multiplication in assembly?
2)The result achieved from this multiplication of proportional value and error signal is 16bit. In my PWM assembly code for motor, I am using 0-127 for forward direction and 128-255 for reverse direction.
How can I use this 16bit data generated from multiplication to give command to my motor. If it was only 8bit it was very easy that I simply check the 8th bit and based on that give direction to drive motor either in forward or reverse direction.
3) If someone can please shed some light on how can I implement integral and derivative terms of PID using assembly.
Please accept my thanks in advance. At the moment my project looks as below:-
**broken link removed**