Arduino is an open-source electronics prototyping platform
-
Indeed it is usefull. If you're interested in hooking up an Arduino with Mango, you might be interested in my post on Jee Labs hardware.
I used the modbus RTU slave code from
http://sites.google.com/site/jpmzometa/arduino-mbrt
for use with JeeNodes to get data into Mango. You can use this with any other Arduino board in order to hook it up with Mango.
-
The problem is that site gives just enough info for us noobs to know its possible. But not enough to actually get it to work. An actual working example with an arduino, LED and Mango would be nice. Look, mango can turn on this LED using this arduino sketch with the LED plugged into analog port 3. or Look, Mango can log the temp and graph it using this arduino sketch and a TMP36 sensor plugged into analog 2.
I can cut and paste and hack like a champ but I'm losing all my hair with this. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285803728/0 -
Hi JointTech,
The sample code initializes the mobus holding register 0 to 123. For your first test, you don't have to do anything else; you can leave the your-code-goes-here part empty .
Next, hook up the Arduino serial port to the machine running Mango and create a Modubus data source.
Then create a data point for holding register 0 and have Mango poll it regularly. If all goes well, you should get the 123 value in your data point.
When this works, you can proceed to put whatever value you would like in the holding register from the your-code-goes-here section. Just assign the value to regs[MB_REG0]. The start_mb_slave() function in the loop runner will take care of responding to modbus master commands.
-
thanks for the reply.
I setup a data source.
[url=http://postimage.org/image/1kmj3h7pg/]and a datapoint [url=http://postimage.org/image/1kmo2396s/]
Mango is not giving me any more errors but I'm not seeing the 123 you mentioned.
[url=http://postimage.org/image/1kxsa9j0k/]could you give me one more kick in the right direction? Mango is making me feel really dense. I suppose my complete lack of understanding of M2M in general isnt helping. :)
-
I feel like I'm hijacking a thread, but in my defense this will help the next guy with just enough knowledge to almost make it, ;)
I think I'm starting to get the coding part.
I "think" this should send the temperature variable to mb_reg0 and mango should be able to map graph the changing temp every 5 seconds. which is what the mango poll rate for that data source is set to.
#include <ModbusSlave.h> //TMP36 Pin Variables int temperaturePin = 3; //the analog pin the TMP36's Vout (sense) pin is connected to //the resolution is 10 mV / degree centigrade //(500 mV offset) to make negative temperatures an option //Arduino sketch example with 2 holding regs: void setup() { /* Modbus setup example, the master must use the same COM parameters */ /* 115200 bps, 8N1, two-device network */ // regs[MB_REG0]=123; // regs[MB_REG1]=456; init_mb_slave(115200, 'n', 0); } void loop() { /* This is all for the Modbus slave */ start_mb_slave(MB_SLAVE, regs, MB_REGS); /* your code goes here */ float temperature = getVoltage(temperaturePin); //getting the voltage reading from the temperature sensor temperature = (temperature - .5) * 100; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) // Serial.println(temperature); //printing the result delay(1000); regs[MB_REG0]=temperature; /* handle write event */ if (written.num_regs) { /// .... written.num_regs=0; } } /* * getVoltage() - returns the voltage on the analog input defined by * pin */ float getVoltage(int pin){ return (analogRead(pin) * .004882814); //converting from a 0 to 1024 digital range // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts }
-
Hah. had to change the modbus data type in the Point Details to 2 byte unsigned integer.
Whoo hoo. I have a datapoint that is showing 123 :)
Ok I think thats good enough to know it works. I will open a new thread if I fail miserably on the next step.
thanks -
I feel like I'm hijacking a thread
I think you hijacked the forum, but no worries. Interesting stuff. I'm glad it all worked out.
-
for posterity's sake. heres a full working example.
http://mango.serotoninsoftware.com/forum/posts/list/0/567.page#2721 -
ok this is working
And now how to set a simple LED on arduino using this method?
I was looking for set the coils register but I can't find nothing
I belive it is not implement yet on arduino modbus slave
Correct me if in wrong
thanks -
this is a really old thread. I spent about 2 weeks total with mango back in 2010... I have no idea. You may want to cross post this at the arduino forum.