Multiple interrupts on 40X-2

airton65

Member
Hi

I can't seem to find in the manual or on the forum whether the multiple interrupts on the x-2 devices can have their own routine, ie three different interrupt routines for three different interrupts off three seperate input pins. I understand that the pins are set.

Thanks

Tony
 

womai

Senior Member
No, there's only a single interrupt routine (starting with the label "interrupt:"). To distinguish between different interrupt sources the routine needs to check the interrupt flags (or in your case, the pin states), they will tell you which one caused the interrupt.
 

boriz

Senior Member
You can set up one interrupt that is triggered for any of the three pins, then in the interrupt routine, branch according to which pin is set. This would work almost identically to 3 interrupts.
 

airton65

Member
Hi,
That's great, so I can do it in a round about way. I am wanting to govern a diesel generator and I have set up a hall effect device (UGN3503U) to detect magnets on the flywheel. I was thinking of counting the clock cycles up untill the UGN3503 created an interrupt. If I do a little averaging over 2 or 3 samples I would get a rate of change and then be able to output a suitable position for a servo (Oatley's Huge Servo Kit). Getting back to the the extra interrupts, I thought that the PicAxe may as well monitor the oil, temp etc of the engine and shut it down in the case of a failure, It may as well be able to do a remote start as well. the auto start units I have seen sense the alternators output and disable the starter at about 50% voltage or when oil pressure builds.

Thank

Tony
 

boriz

Senior Member
“I was thinking of counting the clock cycles up untill the UGN3503 created an interrupt.”

That sounds like the Pic way to do it, but not the Picaxe way :)

Look manual 2, page 42, COUNT command. It count’s the number of events in a specified time interval.

If the RPM is too low for good results using COUNT, then use more magnets, or use the PULSIN command, manual 2, page 135. It measures the time interval between two events.

Both should be capable of doing what you want with no interrupts required.

Both COUNT and PULSIN are ‘blocking commands’. That is, the processing stops on that command until the timeout or the trigger. So while the command is making its measurement, no other processing can take place, EG button testing or whatever.

You can partially compensate for this using short timeouts, like using several magnets. EG, 1 magnet, 60 RPM = 1 event per second. To get a reasonably accurate result using COUNT, would require the COUNT command to be counting (blocking) for say maybe 10 seconds at a time. For two magnets, 5 seconds, for 5 magnets, 2 seconds etc.

PULSIN however would only need 1 second to count 1 rev with 1 magnet @ 60 RPM, and would only be blocking for 1 second. Less for higher RPM, but it begins to lose accuracy at higher RPMs.

So what range of RPM are you expecting to measure? Max,Min,Nom.
 

airton65

Member
Hi Boris

I was going to use the count command and have the UGN3503 count the teeth of the ring gear but couldn't get it to work as per the specification sheet, ie the magnet on the back of the UGN3503. When I looked at the count command I thought, as you said, the time frame between readings would be to long if I wanted to do an average over 2 or 3 periods...I will probably have to whip the flywheel off and machine some holes to fit 8 or 10 magnets, which is not that much work really... Farnell sell a tooth counter hall effect device for about $60.00 Au and I would buy one tomorrow except that the Kabota ring gear is housed into the flywheel and I am not sure I would have the room to position it correctly.

I am not sure whether I am getting a bit carried away with the resolution and trying to ramp the acceleration down as it aproches the target RPM and visa versa, In realality I can't think of anything I would use on the genset that will be upset if the RPM losses or gains 50 RPM, except maybe the alternator itself.

The engine is most economical at 2150RPM which is what my target speed is. If I put a 6KW load on the alternator now ( my hot water service Ha) it slows to about 1800RPM.

I actually got too smart for my own good here (once again) I knew these Kabota diesels had a govener but I didn't realise there was variations of sensitivity. I am on the home strech now as the unit is up and running nicely I just have this govener project to work through and it will be finnished. Great learning experience.

Thanks once again

Tony
 

stocky6409

Senior Member
I do a LOT of work with Kubota engines with my line of work.
I actually use a LM2917 circuit to set the trip point and feed that into our other systems.
I use a single magnet installed on the shaft and that works really very well - multiple magnets works better but for our app a single is just fine.

Another way is to use the same chip and look at the output of the generator coils on the motor (low voltage) and use the freq generated there to set a trip point (under/over speed).

I'm actually working on a engine controller design at the moment with a Picaxe (28x2 - maybe 40x2) and considering use of LM2917 to generate an analog voltage that can be read with the picaxe to indicate speed.

lots of ways to do it - be interested to see what you end up using :)

EDIT:- I'm also looking at watching the output frequency from the alternator and adjusting the engine RPM to maintain 50hz for correct pump operation
 
Last edited:

stocky6409

Senior Member
just thinking - servos tend to "jitter" a bit - not sure about the "mega" servo you say your using.

Another option is to rig up a cable drive to a small linear actuator - like whats used in an electric car seat - maybe a bit smoother action - just use a loop to check rpm and control motor pos via H bridge cct...........

again be interested to see what you go with as I've been working with Kub's for 15 years in very remote and hostile environments.....lots of things to go wrong!


EDIT:- maybe a modified cruise control motor.....cheap and easy to get from wreckers and comes with cable drive attached!
 
Last edited:

airton65

Member
Hi Stocky

I had thought about a cruise control but couldn't find one around here..I haven't made up the servo (windscreen wiper motor etc) yet and will have to wait and see how good that is?

The over voltage is where I wanted to have an interrupt as well as on the oil and temps,, I can't see why it wont work.... but I've said that before

Thanks

Tony
 

stocky6409

Senior Member
for multiple "watch dog" interrupts use i2c and a PCF8574 - use the INT pin to trigger the interrupt then in the interrupt routine read the chip and set "flags" in the main program to act on.

with 1 chip that gives you 8 independant inputs you can read with them all generating interrupts from a single interrupt pin

Connect more chips to same bus and diode OR the INT pins together and you can have LOTS more I/O - this is how i'm getting a lot of i/o on a 28x2

I/m using a couple of chips for inputs with interrupts and a chip for outputs and status LEDS
 

airton65

Member
Just had a look at the PCF8574, it's a very good idea. might be a bit out of my league though with that I2C buisness, I only been using 08M's.

I was thinking that I would only need a couple of interrupts anyway, oil,temp and over frequency or voltage and maybe a kill switch.
Thanks

Tony
 

stocky6409

Senior Member
On our pump apps we use:

Temp
Oil
Fuel
Over Speed
Under Speed
Belt Break
Start
Stop
Remote Start
Remote Stop
Low Level Inhibit
Hi Level Inhibit

and MOST important....E-STOP!
 

airton65

Member
Hi Stocky

I'm thinking for most of those I probably wouldn't need an interrupt because the main program of governing the engine won't really be that intensive, and that is the reason I am trying to get the sample time as short as possible so as I can get a couple of "If pin 2 = 1 goto ##" type lines in there. The more I think about it do I need interrupts at all?? Although I am trying to drive my LCD display as well which is working nicely.

I will get the servo built by the weekend and see if it is jittery. The advantage of the servo is for shutdown in that I don't need to have any form of switch to sense the throttle position for shutdown if it doesn't work I will try and get a cruise control actuator.

In your experance with Kabota's do you find them reliable, We have a 3 in various machines and have never had any trouble in thousands of hours running which is why I got this one.

Thanks
Tony
 

inglewoodpete

Senior Member
Most of those inputs would not need to use an interrupt. You could get away with polled inputs.

Where interrupts are most useful are for short state changes and very quick responses where polling may miss the event or delay the response Eg limit switch or over voltage.

Things like oil pressure or temperature can wait a few 10s or 100s of milliseconds until the next poll occurs.

Edit: airton65 is thinking what I'm thinking. Great bananas think alike!
 
Last edited:

stocky6409

Senior Member
Our controller does a fair bit of "other" stuff as well so we use the "INT" from the PCF chip to flag that something needs looking at so the main loop can do its thing - hey it was just the way i chose to do it :)

Also allows a lot of expandable io on a 28x1/2 with small "add on modules" to the i2c bus for engine/app specific tasks - again suits what i wanted to acheive - just throwing my ideas out there for other to consider!


As for the Kubotas - 99% of the gear we get to work on is Kubota - lots running 24 hours a day on 50 deg C heat or better for thousands of hours a year - yep pretty reliable!
 

airton65

Member
hi guys

I will have a look at I2C setup and see if I can get my head around it, I can see your point about the interrupts.. I built up the servo electronics last night and haven't fitted the feedback pot to the wiper motor yet but at first glance it seems very jittery on a couple of different motors but in fairness I will set it up properly and see.

Thanks again for the feedback

Tony
 
Top