Pages: [1] 2   Go Down
Author Topic: StandardFirmata/Maxuino code + pulse code at the same time - Possible?  (Read 1845 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

I am using an SB-Freeduino v2.2, Max 5, Maxuino/Standard Firmata.

What I want to know is, can I upload an additional code besides StandardFimata/Maxuino, and load both into the arduino and have both codes operate and complete its function at the same time?

For example, if I have several temp sensors, two servos and other functions being performed by Max MSP through the arduino (Freeduino), but I also want to have code that takes square wave pulses, smoothes them out etc and measures the time between the pulses, and displays the time in ms. Then just send the actual resulting time increments to Max MSP?

Maxuino cannot interpret interrupts, so I want to complete the math and derive the final time increments (essentially have the pulse frequency in ms) and just send the final numbers to Max MSP?

I hope I am explaining this clearly enough. I am a Max guy, but have not spent much time with arduino coding by itself... just relied on Max to work in.

-Martin
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What I want to know is, can I upload an additional code besides StandardFimata/Maxuino, and load both into the arduino and have both codes operate and complete its function at the same time?
No. One sketch at a time.
Logged

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

If I were to use an additional microcontroller, I could run upload the code that interprets the signal and converts it into a real-time hertz value that is available as a byte. Then from this second microcontroller, can I run this hertz value/byte into my arduino#1 (one of its inputs) so that that value can be fed into Max MSP via Maxuino?

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If I were to use an additional microcontroller, I could run upload the code that interprets the signal and converts it into a real-time hertz value that is available as a byte. Then from this second microcontroller, can I run this hertz value/byte into my arduino#1 (one of its inputs) so that that value can be fed into Max MSP via Maxuino?
Yes.
Logged

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

Ok, I will keep that in mind as an option.

How will that hertz value/byte register in the arduino#1 inputs? This is probably a dumb question... but do I need 8 inputs to register  a byte? And I would have to be able to get it into Max MSP via Maxuino...
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How will that hertz value/byte register in the arduino#1 inputs?
Depends on how YOU send it.

Quote
This is probably a dumb question... but do I need 8 inputs to register  a byte?
Yes (actually, 10 bits), but not on 8 pins. All the bits come in on the same pin.
Logged

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

I'm still trying to wrap my head around everything. Thanks for the replies, totally appreciated.

Quote
Depends on how YOU send it.
Yes (actually, 10 bits), but not on 8 pins. All the bits come in on the same pin.

What would be the best way to send it, remembering that I can't use interrupts so that it would show up in Max (via Maxuino). Would it be best to send it at regular intervals, say 5 ms, so that the hz value is updated fairly quickly and thus give me little latency with what I'm trying to use it for in Max, yet it wouldn't be too fast to be demanding etc?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Would it be best to send it at regular intervals, say 5 ms, so that the hz value is updated fairly quickly and thus give me little latency with what I'm trying to use it for in Max, yet it wouldn't be too fast to be demanding etc?
I don't know. I don't know what you are trying to do. I don't know what Max MSP expects from the Arduino. Is it expecting some specific sketch to be loaded on the Arduino, like Firmata, or do you have flexibility regarding the Arduino sketch?
Logged

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

I am probably just not explaining very well, sorry.

The arduino#1 would be loaded with StandardFirmata which Maxuino uses to allow Max MSP to communicate with the arduino. This lets us build all our virtual circuitry in Max, and change/update parameters and see the changes immediately in the arduino. Unfortunately Maxuino does not interpret interrupt service routines, which seems to be the best way to have a square-wave pulse signal frequency (or interval between pulses) be accurately measured and displayed.

What I am hoping to do is load arduino#2 with a sketch; code utilizing ISR's that derives the pulse frequency (real-time hertz value) into a byte, and then sends this byte into an arduino #1 input, where it can be processed as a real-time pulse frequency and displayed in Max MSP. So arduino #2 does most of the hard work and utilizes ISR's, and then simply sends its current frequency count into the first arduino which is loaded with the StandardFirmata sketch, and I can build a user interface in Max MSP to display the frequency and apply it.

As long as the frequency is real-time, the updates from arduino #2 to arduino #1 can be sent at intervals 5 ms or 10 ms or even 50 ms apart, and the results would still be smooth enough to be undetectable with the naked eye in the Max MSP interface/display. The further apart the updates, the less cpu demand by Max MSP, although this might be negligible anyway.

Is this making sense? smiley Very possible I am missing a few key concepts... Thanks again for helping.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Very possible I am missing a few key concepts...
I'm afraid so. If you are using StandardFirmata on the Arduino that Max is reading/driving, you would have to figure out how to get Max to read the input from the other board. In effect, you need to implement software serial in Max, in order to read the serial data that the other board is sending.
Logged

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

But isn't that what maxuino is all about -  Maxuino uses Max's built-in serial object to implement OSC style communication to/from the Arduino-compatible hardware ?
Logged

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

http://www.underwater.ca/blog/arduino-to-max-msp
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Maxuino uses Max's built-in serial object to implement OSC style communication to/from the Arduino-compatible hardware ?
Which means that you can't use the serial port to talk to the other Arduino. Which means that you would need to use software serial. But, since you can't modify the StandardFirmata sketch, the software serial needs to be implemented on the driver end. That's Max.

I'd recommend a Mega, but Firmata doesn't play well with Megas, and doesn't expose the other Serial objects anyway.
Logged

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

What about taking the signal value and instead of sending it in the form of a byte from Arduino #2, convert it into a voltage output by arduino #2. Then its simply a voltage registering in an arduino #1 input, 0 - 5 v, like any other sensor?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What about taking the signal value and instead of sending it in the form of a byte from Arduino #2, convert it into a voltage output by arduino #2. Then its simply a voltage registering in an arduino #1 input, 0 - 5 v, like any other sensor?
The only voltage-out capability that the Arduino has is ON, OFF, or PWM, which is a series of ON and OFF pulses close together.

You could probably read this OK on the receiving Arduino. Worth a try, at least. PWM is limited to 256 discrete values, though.
Logged

Pages: [1] 2   Go Up
Jump to: