Pages: [1]   Go Down
Author Topic: Max MSP, maxuino, LM1815 chip, ISR's, trying to have engine RPM displayed in Max  (Read 1201 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,

I want to have my Toyota's engine RPM displayed in Max MSP. So, a rate which needs to be fairly instantaneous to be utilized for RPM-related operations such as servos which open/close variable intake runners etc. It also needs to be accurate and clean. I am using an LM1815 chip (zero crossing detector) which is receiving RPM information from my Toyota's ecu (NE wire). I have it going into one of my arduino digital inputs. For real-time and precision, the Ne signal from the distributor produces 24 pulses per cam revolution. It's a variable reluctor sensor, so the pulses are kinda ugly (among other things, the amplitude varies with RPM)... The LM1815 turns it into a nice square wave, and we can measure from edges (falling edge to falling edge). Time is equal to the time it just took the engine to travel 15 cam degrees or 30 crank degrees, or 12 pulses per revolution.

The problem is, it is meant to utilize ISR's on my arduino. As far as I know (please correct me if i am wrong), ISR's are not interpreted from maxuino into Max.

What I am getting in Max is a fast string of alternating zero's and ones, averaging about the same rate when compared (using the "route" object). I am using "counter" to give me a running tally of all events. At idle the tally comes in at about an event every 2.3 ms. At redline, this increases to an event every .23 ms. But according to the LM1815 application, at redline (7400 RPM) we should be getting about 1480 pulses per second, or a pulse every .676 ms. So obviously I am getting more "events" than just pulses, that are giving me a dirty signal.

My main questions are:
1) I am finding that the objects "timer" and "cpuclock" are not able to measure the time between events... it's too fast. I am using the method shown in "timer" help, the "Clever way to report time between events". I am using cpuclock in the same way. When I use the carry-count output of the counter to reduce the speed of the events (have it output a pulse every 50 or so events) I get some success but its very inconsistent. What is the best way in Max to measure the time between fast events? Is there a way?

2)How can I take a stream of numbers that fluctuates and changes constantly, discard the highest ones, discard the lowest ones, and just take the middle range? Using the "mean" object would include the highs and lows, which I don't want to do. For example, if I get a stream of numbers that average around 200, but I get some obviously out of range low numbers like in the teens, and then some obviously high out-of-range numbers like 600. Then as the RPM increases, the numbers now average around 2000, but i still get those occasional very low and high numbers that are just noise. What is a good way to clean up such data?

What I have tried is making a list and feeding it through "minimum" and "maximum" and mean, but this slows down the real-time response a lot. I have a feeling it is possible using the "route" object somehow, to keep it responsive, but have the route's arguments variable.

3) Some people have successfully been using the LM1815 chip and writing code to the arduino (not using Max/Maxuino at all), and getting the necessary timer information via ISR's. Is it possible to have Max running numerous activities through the arduino, and then having the arduino concurrently execute an additional code of instructions that has been loaded into it that has nothing to do with Max? Can this be done at the same time?

Any help would be much appreciated!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright,
Well, I believe part of my issue might have to do with the serial baud rate. I am just trying to figure out where it all has to be changed/updated.

I can increase it to as high as 115200, and I know it has to be done in the maxuino patch itself (currently has an argument of 57600), but where else do I have to update it? I assume in the arduino itself, via the "StandardFirmata" code, line 291 perhaps [where it says Firmata.begin(57600); ] . Or is it just done at the bottom of the Serial Monitor window in the arduino application, the dropdown menu?

I am also currently getting this error code when I try and upload the (updated baud rate) Standard Firmata to the arduino. It seems to have something to do with the digital-ins/outs:
Code:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h: In function 'void checkDigitalInputs()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:65: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:66: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:67: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:68: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:69: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:70: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:71: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:72: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:73: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:74: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:75: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:76: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:77: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:78: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:79: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:80: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h: In function 'void setup()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata/Boards.h:270: error: too few arguments to function 'unsigned char readPort(byte, byte)'
StandardFirmata:295: error: at this point in file

Any help much appreciated!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I solved the above errors. It had to do with trying to upload the wrong copy of the StandardFirmata.

Currently I also increased the serial baud rate at line 291 [Firmata.begin(115200);], in the arduino window (Serial Monitor drop-down menu), and in the maxuino patch itself. Everything seems to work, but I have not tried the signal source yet to see if the new baud rate is fast enough or makes a difference.

There is not any code as of yet for Maxuino to use interrupts and get them into Max MSP. Does anyone know if it is possible to work around that, and have the fast pulse wave coming into the arduino (digital in), say anywhere between 2 ms and .2 ms, and from that get just a constantly updated rate (Hz etc) float-figure that can be displayed in Max MSP?

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have solved this endeavor.
However, because I was resolved to use Max MSP, I was limited by Maxuino's inability to liaison ISR's from the arduino to Max MSP. The solution was to play to one of Max MSP's strengths - signal analysis.

I "listened" to the car ecu's IGT signal as if it were audio, by running the signal straight into my Presonus Firebox interface which already installed anyway. I then used the Max MSP external object [sigmund~] to analyze and derive the frequency, as well as the Max MSP oscilloscope [scope~] to view the signal. It worked perfectly, and required no smoothing whatsoever. It actually leaves the oem Toyota tacho in the dust for responsiveness and accuracy.

It unfortunately means that the arduino/Maxuino sit this one out... but they are performing many other tasks for me as it is, so... smiley

You Tube video demonstrating the results:
« Last Edit: April 12, 2012, 10:55:47 am by mkloppers » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Mkloppers:

How did you wire your LM1815 to the arduino? I have discovered you project and I found it a very good starting point for a CDI programable arduino project.

Would you please share more details about reading the VR data into arduino?

Thank you in advance
Logged

Pages: [1]   Go Up
Jump to: