Show Posts
Pages: [1] 2 3
1  Using Arduino / Motors, Mechanics, and Power / Re: Cummins Fuel Control on: September 23, 2013, 07:19:25 pm
Apologies for bringing this back from the dead, but has there been any progress on this project?
2  Using Arduino / Project Guidance / 2nd Arduino to handle some tasks - Serial communication? on: April 08, 2013, 06:28:02 pm
Good morning all.

I currently have a project which is utilising a Mega, and it has all the PWM-capable pins in use. They are driving 12 sets of outputs and are written depending on 12 variables;
int circuit1 ~ int circuit12.

It also has 12 digital pins assigned to a relay used in conjunction with each PWM output, and a further 12 used to monitor switches.
It also is using I2C for a RTC module.

I would like to add ethernet so I can have a web interface, and an LCD for visual feedback to the project.
I can't use the ethernet shield directly, as the pins it uses are in use by PWM tasks.
Can the ethernet shield be used on pins other than the standard ones (i believe 10, 11, 12 ,13?)

I can add an I2C LCD so that shouldn't be an issue.

My question is, can I use, say an Arduino Uno, to handle the ethernet tasks, the web page, and the LCD, and use a serial link between the two Arduinos (Mega and Uno) to transfer the data? This would free up some resources on the Mega, and reduce the clutter in the code on the Mega a little.

The web interface ideally would display the values for circuit1 - circuit12, and be able to change them, or alternately run sub routines in the sketch on the Mega which would change them.

In this case, the Uno would have to be able to read the current state of the variables from the Mega, and then if requested, either change those values or run a sub routine based on input from the web page.
The LCD could also be moved over to the UNO, and this would just be displaying the values in a rolling loop kind of thing. .
i.e. Circuit 1 = 200, wait, then clear screen, Circuit 2 = 155, etc etc.

I can work out the display and the web interface on the Uno, but I've never tried to communicate between 2 Arduino's before so I'm not sure how to go about getting the values from the Mega, or sending back a request to change a value or run a routine. Or how to take an input from the webpage running on the Uno, and send that to the Mega.

The boards can be physically located near/next to each other so distance isn't a concern.

Thanks for any guidance.
3  Using Arduino / Project Guidance / Re: Reflective surface, alternatives to mirrors? on: March 15, 2013, 05:21:10 am
old/blank CDs/DVDs??
never tried it but they are designed to reflect a laser when they're read so???
cheap and plentiful and pretty well undamageable?
4  Using Arduino / Project Guidance / Re: Adjustable Duty Cycle PWM signal at low Hz on: March 14, 2013, 07:40:17 pm
At that sort of frequency, you could just use the techniques demonstrated in 'blink without delay' to switch the outputs at the desired times.
I thought that. . and I think I can work out how to get, say a 10Hz squarewave (working out the ms periods of a 10Hz signal etc) but it would always only be at a 50% duty cycle (on for half the period, off for half the period).

I need to work out how to change the duty cycle. .
5  Using Arduino / Project Guidance / Adjustable Duty Cycle PWM signal at low Hz on: March 14, 2013, 07:17:21 pm
Hi all,
just working on a project and was wondering if anyone knew of a library or had some working code to manually creat a PWM-style output signal but at low frequencies.

I need to pulse solenoids to control flow, but the onboard PWM is way too fast for the solenoids to react.

I need to create a signal around the 10Hz - 20Hz range with an adjustable duty cycle.

Ideally I want to be able to ramp the flow up and down over a time period. . eg start at 25% flow and then after 2 seconds the flow has linearly ramped ot 100%.
The frequency needs to be adjustable to suit different style solenoids but would only be a setting it wouldn't need to be dynamic like the duty cycle.

I've had a search and seen ideas where the internal timers are changed to slow down the onboard PWM frequency, but this also affects millis() and other timing functions which are in use in the project.

Cheers for any help.
6  Using Arduino / Project Guidance / Re: Scoop Lights Based on Throttle Position on: July 30, 2012, 03:37:12 am
More than anything, we're hoping it'll have a psychological effect on people so when they look in the rearview mirror
Well, I know what I think when I see stuff like that in the mirror.
It certainly would have a 'psychological effect on people' but I don't think it's the one you're looking for.
(And generally, anything that needs a glowing light in the hood scoop that changes with rpm to 'give them a hint as to how fast he's accelerating' is going to spend most of its time in the rear view mirror!!)
7  Using Arduino / Project Guidance / Re: Reading frequency on: July 28, 2012, 06:28:47 pm
Here is some example code using the above library to calculate 2 different frequencies (and convert to RPM). Using floating point and a fractional frequency.
This is just the frequency parts pulled out of a bigger sketch so this is untested stand alone.

#include <FreqPeriodCounter.h>

const byte counter1Pin = 2;             
const byte counter1Interrupt = 0;
const byte counter2Pin = 3;
const byte counter2Interrupt = 1;

int rpm1;
float hz1;
int rpm2;
float hz2;

FreqPeriodCounter counter1(counter1Pin, micros, 0);
FreqPeriodCounter counter2(counter2Pin, micros, 0);

void setup() {
  attachInterrupt(counter1Interrupt, counter1ISR, RISING);
  attachInterrupt(counter2Interrupt, counter2ISR, RISING);

void loop() {
  if(counter1.ready()) {
    hz1 = (1000000.0/counter1.period);   // period in ms
    rpm1 = (hz1 * 60);
  if(counter2.ready()) {
    hz2 = (1000000.0/counter2.period);
    rpm2 = (hz2 * 60);

void counter1ISR()

void counter2ISR()
8  Using Arduino / Project Guidance / Re: Reading frequency on: July 28, 2012, 06:03:27 pm
I have found this library;
quite helpful for projects like this. You can use 2 inputs (using the 2 interrupt pins) with the code implemented either using the interrupts or polling the counter in the loop.

Works well, you can have it measure Hz directly from the library (in whole numbers) if you're measuring a relatively high frequency, or using a floating point variable and calculate the frequency from the period of pulses if you need a fractional Hz result (if you need to detect small changes in low frequencies).

My project measures the RPM of 2 different shafts, which are relatively low, so I use the fractional option.
Uses a bit more memory that way due to the floating point calculation so if you're reading higher frequencies, the built in counter.hertz() function is better.

9  Using Arduino / Sensors / Re: U-Tube Manometer Level Sensor on: July 27, 2012, 09:21:16 pm
Can you replace the tube manometer entirely with an electronic differential pressure meter? That would open up your interfacing options.
10  Using Arduino / Project Guidance / Re: Car rev limiter on: July 27, 2012, 08:26:53 pm
What car/engine?
What sort of ignition system is in the car?
Is it single coil with a distributor, or individual coils per cylinder?

Knocking out spark to a single coil is pretty rough. . it gives the rev limiter very harsh operation.
Racing ignitions will generally alternate which cylinder they drop, and then make sure that cylinder is fired on the next compression stroke so as not to load up that cylinder with fuel.

The difference is night and day with a digital MSD style ignition limiter to an older 6AL style analog box.
I've run both (in an 8 second carby car) and the digital one is so much smoother, sounds a lot nicer on the engine then the older style.

Fuel cut rev limiting in a boosted application probably doesn't sound great to me either (unless it's a diesel), as it's going to cause a very lean-burn situation in the cylinder it's dropping fuel to (assuming fuel injected?).

Maybe there's an aftermarket option for the computer in your car to allow different RPM limits (for your 2/3 step)?

11  Using Arduino / Programming Questions / Re: Smoothing RPM data on: July 21, 2012, 06:11:13 pm
I would do 2 things:

1. Use a Hall sensor instead of a reed switch to detect the magnets. Contact bounce in the reed switch is likely to cause jitter. There may be less need for smoothing if you eliminate this jitter. Hall sensors cost very little these days.

2. One way of smoothing the output is to measure the time for several rotations instead of just one. You could have the ISR record the times of e.g. the last 8 pulses instead of just the last one, like this (warning: untested code!):

const int nReadings = 8;

volatile unsigned long times[nReadings ];
volatile unsigned char lastReading = 0;

void DSIsr()
  unsigned long DSnow = micros();
  if (DSnow - times[lastReading] > 100)
    lastReading = (lastReading + 1) % nReadings ;
    times[lastReading] = DSnow;


unsigned long refreshcurrentMillis = millis();
  if(refreshcurrentMillis - refreshpreviousMillis > refresh) {
    refreshpreviousMillis = refreshcurrentMillis;
    unsigned int lr = lastReading;
    unsigned long interval = times[lr] - times[(lr + 1) % nReadings];
    unsigned long DSrpm = ((nReadings - 1) * 60000000UL)/interval;
    lcd.setCursor(0, 1);
    lcd.print("  ");
    lcd.print("RPM ");   

I've done the calculation in unsigned long instead of float for better speed, but you can use float if you want to display fractional RPM.

Thanks for that!
Fractional RPM isn't needed, not sure why I used float in my code actually, I think it's code I used from another project that displayed a fractional RPM.

The whole length of the event I'm logging will only be 9 seconds (hopefully a bit less) and the shaft will accelerate from 0 RPM to about 7000 in that 9 seconds. I'm looking for the most accurate RPM calculation I can get to analyse the acceleration rate of the shaft over the 9 seconds. The shaft will have 4 magnets at 90 degree intervals, so there will be 4 'pulses' per revolution.

Will your method give a less accurate or less 'responsive' result then the original calculations, or will the difference be negligible?
12  Using Arduino / Programming Questions / Smoothing RPM data on: July 21, 2012, 05:25:51 am
Hi all,
I'm working on a project which logs the RPM of a shaft; shaft has magnets on it and I'm using a reed switch which pulls an input to ground when a magnet is near. The code is using an interrupt and measuring the period to work out RPM. This works fine. However I'd like to include some 'smoothing' or noise reduction in the data.

My ISR for the rpm calc is as follows;

void DSIsr()
  unsigned long DSnow = micros();
  unsigned long DSinterval = DSnow - DSlastPulseTime;
  if (DSinterval > 100)
    DSrpm = 60000000.0/(DSinterval * DSpulsesPerRev);
    DSlastPulseTime = DSnow;

I then log the result of DSrpm (to SD card eventually but currently just to the Serial output) at an adjustable refresh rate using;

unsigned long refreshcurrentMillis = millis();
  if(refreshcurrentMillis - refreshpreviousMillis > refresh) {
    refreshpreviousMillis = refreshcurrentMillis;
    lcd.setCursor(0, 1);
    lcd.print("  ");
    lcd.print("RPM ");   
    // Serial.println(DSrpm);

'refresh' is 50ms at the moment.

I would like a way to 'average' the rpm results, say over 5 or 10 samples, to smooth the data that I'm getting.

I tried a similar method I've used to smooth analog inputs;

    rawvalue = 0;
    for (int i=0; i< count; i++) rawvalue += analogRead(A1);
    rawvalue = rawvalue / count;

but that doesn't seem to work using an ISR-derived value, as each time the ISR is triggered, DSrpm is re-calculated.

Is there anyway I can use a similar idea to 'average' a few samples of DSrpm and smooth the data??

13  Using Arduino / Project Guidance / Re: Homebrew 2-stroke ignition? on: July 02, 2012, 06:23:57 am

  To get accurate spark timing, you will need many pulses per revolution of the crank. On my 4 cylinder suzuki, it has 22 pulses and a 2 non-pulse are to determine 'TDC on #1 cylinder.

 For a single cylinder engine I would think you need at least 6 pulses per revolution.
Nearly every high performance/drag racing style engine runs an MSD crank trigger ignition. 4 magnets located around a trigger wheel on the balancer at 90 degree intervals corresponding to each 4 TDC positions (V8). A pickup fires the ignition each time a magnet flies past.
These engines turn 10,000 rpm plus and make thousands of horsepower.

The trick I can see here is having the pickup trigger advanced some amount before you actually want the ignition to fire and work a delay into the controller. This allows you time for processing. (I've got no idea how much timing a 2 stroke engine runs but to use my drag engine as an example, we run (depending on gear, fuel, weather and other tune up factors) somewhere around 38 degrees BTDC ignition timing. The pickup is actually adjusted to be somewhere around 40 - 42 degrees. The processing in the ignition controller then fires at 38 (as seen if you check the timing with a timing light).

You can then work a 'retard' curve into your controller, referencing RPM or boost/MAP or any other factor you care to use. Remember, the controller can only retard the timing from your base setting. It can't predict into the future to fire before the trigger, it can only trigger after the trigger, so your pickup must be set at the maximum amount of advance you want anywhere in the curve, then retard back from that value in your curve.

In my case we pull 1 degree out when it shifts from low to top gear, and can ramp a few degrees out on launch if traction is marginal, or plot an entire curve for each gear based on RPM or time.

The maths/interfacing for an Arduino to do this and whether it can actually do the job; I have no idea. But I do know it works with only 1 reference per cylinder TDC event in some pretty high performance applications, so it may well be possible.

Have fun with it!
14  Using Arduino / Project Guidance / Re: Automatic engine/generator control on: June 19, 2012, 05:19:50 am
Interesting project idea!

How are you controlling engine speed of the generator unit?

Also, you'll probably find you'll get oil pressure > 5psi just on the starter, especially when the oil is cold. Might need a higher set point, or use an engine RPM signal or the output of the alternator/generator to signal 'engine started' or 'engine running' to the controller.

Have fun and I look forward to seeing this project progress!
15  Using Arduino / Programming Questions / Re: Read a 2-variable 'MAP' on: February 20, 2012, 05:44:42 am
Yes. It's trivial, even. Just define a 2D array, called map. The value of interest then is map[A-1][B-1].
Thanks for the quick reply!
I'll have to hunt up an example of how to use Arrays.

Is it possible to interpolate values between the finite values defined?
Probably just for the inputs, the outputs can remain discrete and defined in the 'map'.(array?).

so, if input A is between 2 & 3, (rather than exactly 1 or 2), what is the output?
Pages: [1] 2 3