Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Question about relays: update frequency (http://www.chiefdelphi.com/forums/showthread.php?t=46603)

JJG13 16-04-2006 09:20

Question about relays: update frequency
 
For the past couple of years the logic in my 26.2 ms loop area has looked like this:

GetData(&rxdata);
set all pwms to neutral and set all relays (fwd and rev) to 0
execute logic that sets pwms and relays
PutData(&txdata);

By setting all pwms and relays to neutral, I know that nothing will move if I don't set it and outputs from the previous pass won't interfere with the current pass. Also, if I need to put relay1 forward, all I have to do is write relay1_fwd = 1 and not worry about relay1_rev because I know it is set to zero at the beginning.

This year I realized that PutData handles the pwms(and a few other things) but not the relays. In fact, I have no idea how or how quickly the master processor sets the relays after it is set in code. This makes me think that my habit of resetting all relays at the start of each loop may not be such a good idea if enough time elapses between the time I set the relays to off at the start and I set the relays to what I want them to be to adversely effect the robot.

I've had no problems doing this so far but, in order to sleep soundly, I need to know how quickly the master processor processes what I set the relays to and if I will ever get burned by zeroing the relays before each pass.

Kevin Sevcik 16-04-2006 10:16

Re: Question about relays: update frequency
 
The master processor has no control at all over the relays. If you'll look in ifi_aliases.h, you'll see that the relays are all aliased off pins on the user processor. So the relays get updated literally the instant* you set them to something in your code. So if relay1_fwd is 1 before your loop, and you set it to 0, and then set it back to 1 again, you'll actually be getting a veeeery short pulse from 0 to 1 on the output pin. This is almost certainly negligible and won't affect anything, but it will be there. Plus you're wasting valuable processor cycles clearing variables. :D Why, back in my day our user processor was a monkey with a calculator and.....

*actually an instant plus a few nanoseconds of propagation delay.

JJG13 16-04-2006 18:12

Re: Question about relays: update frequency
 
Quote:

Originally Posted by Kevin Sevcik
The master processor has no control at all over the relays. If you'll look in ifi_aliases.h, you'll see that the relays are all aliased off pins on the user processor. So the relays get updated literally the instant* you set them to something in your code. So if relay1_fwd is 1 before your loop, and you set it to 0, and then set it back to 1 again, you'll actually be getting a veeeery short pulse from 0 to 1 on the output pin. This is almost certainly negligible and won't affect anything, but it will be there. Plus you're wasting valuable processor cycles clearing variables. :D Why, back in my day our user processor was a monkey with a calculator and.....

*actually an instant plus a few nanoseconds of propagation delay.


So that's what all the LATEbits stuff is...

In that case, it might be possible to create a "poor man's speed controller" by using a high resolution timer to set or zero relays based on how fast you want the motor to run. Could be useful if you have too many servos taking up PWM outputs.

Joe Ross 16-04-2006 19:16

Re: Question about relays: update frequency
 
Quote:

Originally Posted by JJG13
So that's what all the LATEbits stuff is...

In that case, it might be possible to create a "poor man's speed controller" by using a high resolution timer to set or zero relays based on how fast you want the motor to run. Could be useful if you have too many servos taking up PWM outputs.

They are rated for 6 operations a minute at full load, so that would be an extremely slow PWM ;)

http://www.ifirobotics.com/spike.shtml

Matt Krass 16-04-2006 21:22

Re: Question about relays: update frequency
 
Quote:

Originally Posted by Joe Ross
They are rated for 6 operations a minute at full load, so that would be an extremely slow PWM ;)

http://www.ifirobotics.com/spike.shtml


That's the Spike, not the output. I believe the output would be considerably faster.

Kevin Sevcik 16-04-2006 22:43

Re: Question about relays: update frequency
 
You'd have a fun time wiring it. The red and white pins are both signal on the relay ports, so you'd have to make sure you're pulsing the right one. You'd never use them as servo outputs because the red wire is signal, so you wouldn't get the 7.2V to power the servo. And to top it off, you'd have the same interrupt problem that the Generate_PWMs() has for PWM13-16. But yes, it could be done in theory.


All times are GMT -5. The time now is 20:03.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi