servo driving
Moderator: Benj
servo driving
Hello Ben,
Regarding your routine for solar tracker. I run in simulation mode the routine and it seems that the timer does not work because the macro scan for light is never being called!
On the orher hand I think that I might doing something wrong or could it be that the interrupt does not simulate? Do I have to do something in order for the interrupt to work in simulation mode?
Also Ben, what kind of servos does this routine require? I mean the degrees of rotation!
Thank you,
Best Regards,
Andreas Achilleos
Regarding your routine for solar tracker. I run in simulation mode the routine and it seems that the timer does not work because the macro scan for light is never being called!
On the orher hand I think that I might doing something wrong or could it be that the interrupt does not simulate? Do I have to do something in order for the interrupt to work in simulation mode?
Also Ben, what kind of servos does this routine require? I mean the degrees of rotation!
Thank you,
Best Regards,
Andreas Achilleos
Last edited by achillis1 on Fri May 27, 2011 1:42 pm, edited 1 time in total.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: servo driving
Hi Achilleos,
I have tried the Solar_Tracker flowchart in question, and it does simulate, but it does take about 38 seconds to access interrupt macro (well it does on this old xp win version). I suppose it could depend on how fast your PC operating system to how fast interrupt routine is accessed?
But I could be wrong on that point.
It is timer1 and timer2 which does not simulate at all.
If I am simulating within flowcode, and using timer1 or timer2, I just add a call macro function at the bottom of main to access macro, then delete it when finished testing.
Have you tried right clicking and select toggle breakpoint on the Flag=1 calculation within Scan_For_LIght interrupt macro?
Martin
I have tried the Solar_Tracker flowchart in question, and it does simulate, but it does take about 38 seconds to access interrupt macro (well it does on this old xp win version). I suppose it could depend on how fast your PC operating system to how fast interrupt routine is accessed?
But I could be wrong on that point.
It is timer1 and timer2 which does not simulate at all.
If I am simulating within flowcode, and using timer1 or timer2, I just add a call macro function at the bottom of main to access macro, then delete it when finished testing.
Have you tried right clicking and select toggle breakpoint on the Flag=1 calculation within Scan_For_LIght interrupt macro?
Martin
Martin
Re: servo driving
Ben, I have a request, can you attach another photo of you minature solar project at the article you wrote? MX013 - Solar Panel Light Tracking System
Also you mention in it that the servo-LDR scans every two minutes but the interrupt for the macro that sets the flag to 1 in order to scan fro light is set to be called 9000 times per two minutes!!!!
Also you mention in it that the servo-LDR scans every two minutes but the interrupt for the macro that sets the flag to 1 in order to scan fro light is set to be called 9000 times per two minutes!!!!
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: servo driving
Hello,
Im afraid the program doesn't really simulate as a high speed interrupt is required. The Flowcode timer0 simulation is not great and seems to be firing under simulation about every 30 seconds.
The actual hardware has also been cannibalized so I cannot take another photo. I can however detail the connections if you need them.
The scan for light macro is called 9000 times per second on hardware and this sets the flag which then allows the main to continue.
For timer count 0 - 1023 (14 seconds) the servo's connected to the LDR are moved to try to sense the maximum light level.
For timer count 1024 - 8999 (106 seconds) the servo's connected to the solar panel move into the optimum position and then remain there until the count reaches 9000 and is reset back to 0.
Im afraid the program doesn't really simulate as a high speed interrupt is required. The Flowcode timer0 simulation is not great and seems to be firing under simulation about every 30 seconds.
The actual hardware has also been cannibalized so I cannot take another photo. I can however detail the connections if you need them.
The scan for light macro is called 9000 times per second on hardware and this sets the flag which then allows the main to continue.
For timer count 0 - 1023 (14 seconds) the servo's connected to the LDR are moved to try to sense the maximum light level.
For timer count 1024 - 8999 (106 seconds) the servo's connected to the solar panel move into the optimum position and then remain there until the count reaches 9000 and is reset back to 0.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: servo driving
Hello,
The answer is probably yes you can but it would be very tricky to get it right.
The simulation does not use the timer 1 instead the simulation just goes off the values you pass to the component macros so you should have no problems with this.
The problem with the solar tracker program simulation is that the timer 0 interrupt runs very infrequently. This is not the case on the hardware.
As medelec suggested try adding a call to the interrupt macro somewhere in the while 1 loop and see if this help the simulation to run better.
The answer is probably yes you can but it would be very tricky to get it right.
The simulation does not use the timer 1 instead the simulation just goes off the values you pass to the component macros so you should have no problems with this.
The problem with the solar tracker program simulation is that the timer 0 interrupt runs very infrequently. This is not the case on the hardware.
As medelec suggested try adding a call to the interrupt macro somewhere in the while 1 loop and see if this help the simulation to run better.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: servo driving
Hello,
I see what you mean.
Actually my case here is that, dowloading the different routines ( servo examples from Matrix, my own, forum user's) I kind of getting different responses from the servo!!!!!
At 90% the servo seems that it is going to behave as the routine says but usually, either it stops, or behaving strange or rotates at different degrees!
So my guess is that a ''good'' servo driving routine might need some ''trick'' in order to work!
E.g. I dowload a routine that it will send a command via macro to the servo and then trhe servo suppose to go to point 1, have a delay there and go to point 200. When I test in hardware the servo goes to some point and then without delay comes back and maybe again will make some other movements 2 or three times and then stop. Also sometimes when it finishes the movements the servo stays enabled(when I try to rotate by hand it resists) and some times it just powers off and all that with the same routine!
Is my servo haunted!!!!
I had not had the chance to work with Ben's routine cause I got no LDR setup.
I see what you mean.
Actually my case here is that, dowloading the different routines ( servo examples from Matrix, my own, forum user's) I kind of getting different responses from the servo!!!!!
At 90% the servo seems that it is going to behave as the routine says but usually, either it stops, or behaving strange or rotates at different degrees!
So my guess is that a ''good'' servo driving routine might need some ''trick'' in order to work!
E.g. I dowload a routine that it will send a command via macro to the servo and then trhe servo suppose to go to point 1, have a delay there and go to point 200. When I test in hardware the servo goes to some point and then without delay comes back and maybe again will make some other movements 2 or three times and then stop. Also sometimes when it finishes the movements the servo stays enabled(when I try to rotate by hand it resists) and some times it just powers off and all that with the same routine!
Is my servo haunted!!!!
I had not had the chance to work with Ben's routine cause I got no LDR setup.
Re: servo driving
Hello Ben,
I am trying to set the PWM cycle to 1.75 ms = 1750 us and it does not reach up to there, it goes up to 833.3333 us.
If I am going to drive a servo via the PWM don't I have to sent pulses of 1.25, 1.5 and 1.75 ms?
The pulses have to be sent in every 2 ms. Will I controll the 2ms via the timer interrupt?
Thank you,
Andreas Achilleos
I am trying to set the PWM cycle to 1.75 ms = 1750 us and it does not reach up to there, it goes up to 833.3333 us.
If I am going to drive a servo via the PWM don't I have to sent pulses of 1.25, 1.5 and 1.75 ms?
The pulses have to be sent in every 2 ms. Will I controll the 2ms via the timer interrupt?
Thank you,
Andreas Achilleos
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: servo driving
Hello Andreas,
Which family of devices are you using? and are you sure your oscillator configuration and clock speed are defined correctly in Flowcode? Have you done a 1 second flasher test to confirm everything is ok? Controlling a servo using only the PWM is going to be a absolute nightmare and probably wont work.
Which family of devices are you using? and are you sure your oscillator configuration and clock speed are defined correctly in Flowcode? Have you done a 1 second flasher test to confirm everything is ok? Controlling a servo using only the PWM is going to be a absolute nightmare and probably wont work.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel