Dummies guide to interrupts
Hello,
I do have a question about using interrupts.·I'm using SX/B.
I've read that using interrupts can yield inconsistent results when using commands such ac RCTIME and other time sensitive commands in the main program. Can I solve this by having the interrupt run continuously? This may throw off a result from a RCTIME command as to not be the real time, but as long as the result is consistant - I don't see the big deal.
I would like to use the interrupt to read a frequency so it would be running continuously.
I'm still having a few issues setting up a program to use interrupts, as at this point I find the examples a bit confusing so I don't have a specific example to reference. Also I'm fairly new at this also.
Thanks for any help,
Alex
I do have a question about using interrupts.·I'm using SX/B.
I've read that using interrupts can yield inconsistent results when using commands such ac RCTIME and other time sensitive commands in the main program. Can I solve this by having the interrupt run continuously? This may throw off a result from a RCTIME command as to not be the real time, but as long as the result is consistant - I don't see the big deal.
I would like to use the interrupt to read a frequency so it would be running continuously.
I'm still having a few issues setting up a program to use interrupts, as at this point I find the examples a bit confusing so I don't have a specific example to reference. Also I'm fairly new at this also.
Thanks for any help,
Alex
Comments
There are several ways to handle this. The trick is to make the interrupt routine take the same amount of time everytime it is run.
You also want the interrupt to run very often, but be very quick. This will give the most consistant results.
The other method is to incorporate the RCTIME procedure into the interrupt routine.
Can you post your code ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
I could be wrong, but it looks like your trying to fine tune a fuel injection system. Products like the K&N Power Comander for EFI motorcycles are just pulse strechers.
Here is my code without interrupts as I don't have a workable code for using them. This is what·I have come up with so far. I'm new to this so it may look a bit crude·
I'm reading a square input frequency in the range of about 70hz to almost 200hz, so we are talking slow freqs here. The output frequency does not need to be in sync with the input frequency.
I use the PULSIN command to read the input frequency, then read the potentiometer using RCTIME. The capacitor is small - 0.01 uF so I·was hoping to squeeze than in between a pulse and it appears to work. The output I get from the RCTIME is 0 to 53 so I use the IF THEN command to round off a value above 50 to 50 to use easier numbers.
Then I do a calculation to apply the pot reading to change the PAUSEUS values to make a square output frequency. This looks a bit messy, but trying to get it to work and then I'll make it more efficient.
This is very basically working with 2 problems.
1. The output frequency jumps between 75 and 81 hz. I would assume due to the PULSIN command - hence the reason·I'd like to use·interrupts.
2. The pot only changes the on and off duty of the output freqency, not the actual frequency. Increasing the pot makes the HIGHs longer and the LOWs shorter with the frequency being the same. Can't really figure out why this is happening, but not overly concerned with it at this point, as I believe I need to use interrupts to solve #1.
Capt. Quirk,
Yes, this is for an EFI. I'm trying to slow down the output freq of a Manifold air pressure sensor to get the ECU to cut back on the fuel delivered to the engine. I see those K&N power commanders are for specific applications, which I don't fall under. I have looked for a product to do this online, but haven't found anything yet. Making my own is very educational for me too. Also this would be easy to change the code to get it to work for other ECU's.
Thanks,
Alex
This could be done with interrupts, but it's going to be messy because all of the functions will have to be done in the interrupt routine. 1) Read the input pulse width, 2) Read the pot, 3) Output a frequency.
A MUCH easier way would be to use the SX48 protoboard and use one of the hardware timers to generate the output frequency. Now you don't need interrupts at all. Just use the existing code to read the input frequency (with PULSIN) and the pot (with RCTIME).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
My output would be only about a 10-20% freq change from the input. I'll look into your solution with the ADC.
Bean,
I like your solution about the SX48. It's relatively cheap too.
The SX48 can then do those 2 things at once? That timer will run independently from the rest of the program? Sounds like a good, staightforward·solution. I'll have to order one, and play with it.
Just to be clear the input freq will be changing often, pretty much whenever you push on or let off of the gas pedal so the output will have to change with it to keep the vehicle driveable.
Which commands will this be using to run the extra timer to create a seperate frequency so I can begin reading up on this while waiting for the chip to come?
Thanks for the help,
Alex
The SX48 has two 16-bit timers with prescalers.
Look in the SX/B help file under the TIMER command.
For generating pulses you just "set it and forget it".
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Edit: New code posted -- original contained error (sorry).
Post Edited (JonnyMac) : 8/10/2007 8:29:03 PM GMT
Thanks so much for the program! I'll try it out and see how it works, that sure gives me a good example on using interrupts also. I'll order that ADC chip along with the SX48 board and try both.
Bean,
Thanks for pointing me in the right direction, that will get me started.
Thanks so much guys!!
Alex
Thanks for the program. I just ordered a couple of the the ADC0831 chips. Also the SX48 board to try this with the TIMER command.
Thanks for you help,
Alex