[Logo] Mango Community
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Arduino and Mango Step by step working example  XML
Forum Index » How-To
Author Message
JointTech

Initiate

Joined: 29/09/2010 22:22:17
Messages: 9
Offline

1. Buy or make a Arduino

2. Download the latest Arduino software I'm using 0020. http://arduino.cc/en/Main/Software

3. If you are using Arduino Duemilanove or a similar board that runs off USB you’ll have to install the USB drivers. You can find them in the Arduino folder you just downloaded.

4. plug in a TMP36 temp sensor as shown here: http://tinyurl.com/plbx38
Plug it into Analog port 3 instead of 0 as shown in the link.

5. Grab the modbus library from http://www.tucsni.nl/jee/ModbusSlave.zip
you should check his site http://www.tucsni.nl/jee/ he actually says to use the new version here: http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave
but I havent tested it.

6. Unzip modbusslave.zip to your_arduino_install\libraries\ModBusSlave

7. open the arduino IDE

8. Paste the following code:


9. upload the code to your Arduino.

10. Install Mango

11. Create a new data source.


12. Create a new datapoint


13. you should now be seeing the current temperature updating every 5 seconds on your datapoint.
You can breathe hard on your tmp36 to see the temp go up in mango.

have fun.
hope this helps somebody as it took me about 2 days of scouring the net to make it finally work.
mlohbihler

Master
[Avatar]

Joined: 01/03/2007 22:48:52
Messages: 1847
Offline

Nice. Thanks.

Best regards,
Matthew Lohbihler
jose francisco

Initiate

Joined: 01/10/2010 07:30:14
Messages: 39
Offline

Hello.

I'm trying to compile the sketch buy i get an error in "init_mb_slave(...)" not declared function.

I think that the library i've got is newer because in new examples the configuration is done in this way:

mbs.configure(SLAVE,BAUD,PARITY,TXENPIN);

Can you comment this issue?
thanks
JointTech

Initiate

Joined: 29/09/2010 22:22:17
Messages: 9
Offline

I would use the library here: http://www.tucsni.nl/jee/ModbusSlave.zip
other than that I have no idea. probably question better for the arduino forums as well.
jose francisco

Initiate

Joined: 01/10/2010 07:30:14
Messages: 39
Offline

Sketch for new library from http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave

With this code you can:
-See the status of pin 2 in mango (MB_REG0)
-set the status of pin 13 with mango (MB_CTRL)

use offset 0,1,... in mango to use MB_REG0, MB_CTRL, MB_TIME,...




JointTech

Initiate

Joined: 29/09/2010 22:22:17
Messages: 9
Offline

Nice I was struggling with setting values. Ill have to give this a try.
relristein

Initiate

Joined: 04/07/2012 12:50:18
Messages: 4
Offline

Hi,

I have a one question. I use the modbus serial for comunication. It is script:

#include <ModbusSlave.h>
/* First step MBS: create an instance */
ModbusSlave mbs;
/* slave registers */
enum {

MB_CTRL, /* Led control on, off or blink */
MB_TIME, /* blink time in milliseconds */
MB_CNT, /* count the number of blinks */
MB_REGS /* total number of registers on slave */

};


int regs[MB_REGS];
int ledPin = 13;

void setup()
{

/* the Modbus slave configuration parameters */
const unsigned char SLAVE = 1;
const long BAUD = 9600;
const char PARITY = 'n';
const char TXENPIN = 1;
/* Second step MBS: configure */
mbs.configure(SLAVE,BAUD,PARITY,TXENPIN);
pinMode(ledPin, OUTPUT);


}

void loop()

{

/* Third and las step MBS: update in loop*/

mbs.update(regs, MB_REGS);

if(regs[MB_CTRL]==1)

{

digitalWrite(ledPin,1);

}

else{

digitalWrite(ledPin,0);

}

}


********************
But i want a blink effect in led and i modified the script:

if(regs[MB_CTRL]==1)
{
digitalWrite(ledPin,1);
delay(3000);
digitalWrite(ledPin,0);
delay(3000);
}
else{
digitalWrite(ledPin,0);
}
}

Well, when i set the bit 1, the led blink but it don't enter in the else.

Anyone had the same problem with supervisory and script?

tank's


*sorry, my english is very weak.
 
Forum Index » How-To
Go to:   
Powered by JForum 2.1.9 © JForum Team