Hi, I’m new to arduino, but i’ve spent many hours looking at examples and reading in forums. I have a long history with electronics but with a big gap during the changes from discrete chips to microcomputer controls. I am usingan Arduino Uno, I’m wanting to replace the throttle control on my small generator as the existing one died.
I have the notion that by measuring speed (o/p frequency) of the gen and comparing to a desired frequency to produce a speed hi/low flag then driving the unipolar motor (which is a 28BYJ) CW/CCW i could achieve the result i want. I am able to measure frequency (using a sig generator) and display it on the Uno serial monitor. I am able to drive the stepper both directions using several of the example sketches, and it can operate fast enough to do the job - must be able to as that’s what is on the generator engine.
My problem is that i can’t stitch the two sketches together to drive the stepper up or down as determined by the speed hi/low flag, it just oscillates.
The sketch also slows down enormously once i ‘engage’ the stepper up/down drive code. I am using “If” statements to get ‘increase’ or ‘reduce’ flag in the Uno. I’m driving the sig generator and the uln2003 board from a supply separate from the uno and i am using a common ground.
As I’ve spent many many hours trying to get this to work with no success, I am hoping that I can get a pointer or two from the wiser heads in this forum. I’ve attached the sketch. (I know I’ll need refinements to properly tune the response, its one step at a time for the present).
Thanks in advance for any help offered.
enginethrottlecontrol_MP_rev3-1jun20.ino (2.14 KB)