Need to simulate an interrupt
T Chap
Posts: 4,198
I was having a problem with a circuit, and someone suggested a remedy whereas I take an input to the Prop, and on a high pulse turn off an output for a specified time. That time off may range from 10us to 20us. I am trying to learn whether this can be done in Spin or is assembly req'd. I can devote a cog to it, but there are 3 pins to monitor and 3 pins to switch depending on the input state. My understanding is that in Spin 80k instructions can run a sec. If there are 3 pins to monitor, and 3 outputs to manage, is this time doable in Spin? I can't write assembly so I hope it can.
Post Edited (originator99) : 10/5/2006 5:36:03 AM GMT
Post Edited (originator99) : 10/5/2006 5:36:03 AM GMT
Comments
Read the pins initially to create a mask ... subsequent readings through WAITPNE or WAITPEQ will cause a "Propeller interrupt" if the state of the pins change.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
For current reguation, I am going to monitor a sense resistor, trip a comparator at 2 amps(.2 volts on the REF pin on the comp). The comparator goes to a pin on the Prop, the respective output pin is attached to a quad AND gate that is receiving 4 phase signals from the Prop as well for stepper control. When the comp is tripped, the Prop turns off the pin to the AND for x duration, the coil de-energizes, the comp drops, and the whole thing starts over. The concept is true fixed off time after every over limit current.
This describes one of 3 sets, there are actually 3 comparators, 3 AND gates to manage.
Post Edited (originator99) : 10/5/2006 5:51:26 AM GMT
Just FYI Anything below * 5 doesn't work, 5 will run, but 4,3,2,1 = 0 out. Once I get my circuit dialed in, I believe this will be just what I need.
Thanks a million Mike, you are the man!
Post Edited (originator99) : 10/5/2006 10:11:01 AM GMT
This is because there is a finite amount of time required for the waitcnt instruction to execute. 381 clocks in Spin to be exact.
In the formula:
time := (clkfreq / 1_000_000) * 10 ' clock ticks for 10us
If clkfreq equals 80MHz, then at * 5 you get a result of 400. * 4 you get 320 which is below the required 381 clocks of the
waitcnt instruction, so what happens is that you have to "wait" for the cnt to overflow at 32-bits and loop back around.
This takes about 54 seconds at 80 MHz.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I have been struggling for many hours trying to solve way to use the compartor interrupt Mike created to set up a fixed off state for 2 of 4 pins that are turning on in sequence. The two pins being one of two coils.
For example
1010 is Coil 1A high and Coil2A high
There is sense R on both coils, each with their own comparator, and inputs to the Prop. In the Spin file below, 6 is comp1, 7 is comp2 in. I want to take Mikes code, and instead of firing an output to external parts, I want to do this:
IF Comp1 = 0 hold CoilA off for a fixed time(presetable), i.e. 5 us, then let it come back on, if it were to be on according to the indes table that it. If such a case as the motor move was complete, it should not come back on as it would cause problems.
Motor Move:
1010 'appropriate index location turns on in the sequence
IF Comp 1 = 0 then
00_10 CoilA off, CoilB stays unaffected
wait 5 us
10_10 CoilA back, CoilB stays unaffected.
Same capability for CoilB
The second problem is, I want to apply full power on each initial motor move, and then after a fixed time allow the comparators to take affect as needed for regulation. I am having major problems leaving the comps in full time, while the motors are stopped and PWMing, they don't want to ramp back up while the PWM is still present. So, I am bringing the whole ball of wax inside the Prop to deal with the masking and fixed off time PWM.
I have tried a lot of ways, and nothing is working right. One effort was to affect the pins from another function, but it was not changing anything on the pins for some reason.
Any advice on a concept would be greatly appreciated.
Post Edited (originator99) : 10/6/2006 11:46:05 AM GMT