Show Posts
Pages: [1] 2 3 ... 24
1  Using Arduino / Networking, Protocols, and Devices / Re: Probem witch SimpleModbus and delay on: September 24, 2014, 09:43:52 am
CraigF is correct.

Plus you do the following
Code:
unsigned long tiempo;

Then without equating it to anything you promptly do the following
Code:
if(millis() - tiempo > RETARDO_SENSORES)

That variable possibly is zero, but you need to assign it something like the previous millis() for it to make any sort of sense.

Look at examples of how to use a non-blocking delay correctly.
____
Paul
2  Community / Website and Forum / [Resolved] Re: Potential forum database index issue on: September 24, 2014, 12:46:57 am
It seems there is no issue, and has been cleared up by the OP of the thread.
Sorry for any concerns.
____
Paul
3  Community / Website and Forum / [Resolved] Potential forum database index issue on: September 23, 2014, 10:41:14 pm
Something I noticed just now on the following topic is at post reply #9 by the OP, the code presented has nothing to do with the thread topic and thought I should raise right away, in case it is a problem.

Post http://forum.arduino.cc/index.php?topic=267723.msg1892556#msg1892556

You'll notice the code has nothing to do with that topic and I beleive comes from another thread.

Unless the OP mistakenly placed other code there, which I didn't noticed earlier, then I'm concerned the forum database has messed up something here.

I have re-freshed with a clean page load, but the code stays the same.

Is this a possibility?
____
Paul
4  Using Arduino / Networking, Protocols, and Devices / Re: Parsing, Converting, and Storing Data from a Modbus TCP Response on: September 23, 2014, 10:33:51 pm
jwill, I have just noticed something that I don't understand in your post #9.

Why is the code presented in that reply nothing to do with the code you initially presented?
It has nothing to do with Modbus at all.
Unless something is going wrong with the forum's server database and got its knickers in a knot, I'm lost.

Can you shed any light on it?
____
Paul
5  Using Arduino / Networking, Protocols, and Devices / Re: Parsing, Converting, and Storing Data from a Modbus TCP Response on: September 23, 2014, 10:18:22 pm
You can try to conect to the midnite solar controller from your computer and communicate to it with a modbus application that allows you to set exactly the device parameters and then see what comes back.

What sort of setup do you run there, a computer with Linux or Windows or a Mac with OSX?
There are a number of utilities for these systems that might offer some additional help.

PS, sent you a PM.
____
Paul
6  Using Arduino / Networking, Protocols, and Devices / Re: Arduino posting Data to mySQL via php script on Remote server on: September 23, 2014, 11:00:34 am
I've only done a quick amount of work on it so far, it needs more work, especially to get rid of all strings.

If you are simply passing strings to the php script, think about sending an int and have the php interpret it and generate the string at that point.

Anyway, you can have a look at your code here https://www.dropbox.com/s/83j62vcy50fgxq7/coop.cpp?dl=0
You'll notice a few changes that I hope you will be ok with, it should be somewhat of an improvement.

I don't have use any onewire or Dallas things, but with that commented out it compiles ok.
____
Paul
7  Using Arduino / Networking, Protocols, and Devices / Re: Arduino posting Data to mySQL via php script on Remote server on: September 23, 2014, 10:25:30 am
Chris, I've copied your code and putting it through the rockwallaby blender, not sure what it will spit out  smiley-grin

But in that sprintf statement you are assigning a float var to a unsigned long, for example;
Code:
sprintf(postData, "id=live&iTemp=%lu&oTemp=%i&lLevel=%i&wDoor=%i&cDoor=%i&wLevel=%i&wPump=%i&rBarrel=%i&vFan=%i",
          insideTemperature,
          outsideTemperature,

In my IDE it tells me that insideTemperature is a float and your first token on the sprintf line wants a %lu, which is unsigned long.

There should be no reason to use any string class at all.
I never use it in any of my programs, ever.

Should have something after a sleep  smiley-sleep
Oh, and your code is not long at all.
PS, some of those delay(...) in your main loop can just go, I mean, they can just go.
____
Paul
8  Using Arduino / Networking, Protocols, and Devices / Re: Parsing, Converting, and Storing Data from a Modbus TCP Response on: September 23, 2014, 01:57:21 am
For your HTTP sending, have a look at my suggestion and comment on this thread in this same forum section.
http://forum.arduino.cc/index.php?topic=268457.msg1892482#msg1892482

You may be be able to make it more effective and readable by using a such a method, rather than lots of traffic with those client.prints(...).
Good luck with the testing.

oh, heck, my gumboots filled up, oh well  smiley-grin
____
Paul
9  Using Arduino / Networking, Protocols, and Devices / Re: Arduino posting Data to mySQL via php script on Remote server on: September 22, 2014, 11:59:06 pm
I can understand when you say you are at your wits end, I, myself went through this a while ago.

Have a look at these two snippets of code I use previously in my setup, where I was having the Arduino POST data to my host where a PHP script then took the data and placed it into a SQL database for retrieving by a web app later on.

The routines in the link are direct from my code and so use my variables, just modify to suit yourself.
The first routine, you call from main loop() at your defined set period of time, say every 5 or 15 seconds, whatevery you like.
It prepares the data into a buffer from the list of variables.
With this method you can define any format you like, whether that be JSON or a simple list.

The first routine then calls the second routine which does the actual sending of data to your host site.
There are sections commented out which you can un-comment to get feedback via your serial port from your host site to see how it if all went well.

Insert into your host details in the code where I think you will see I have placed tokens.

You will of course need the setup() and main loop() with your ethernet setup correctly to make all this work.
But, the code comes direct from my system which worked very well, until I took a different path.

On dropbox https://www.dropbox.com/s/hly6v2vmqn303u0/arduino-http-post.cpp?dl=0

PS, just noticing you mention POST in your title but from your code you seem to be using the GET method, which are you wanting to use?

I used POST previously to send data from my Arduino to the host site as it allows for larger amounts of nicely formatted data, such as JSON.

PS No 2, you will certainly have issues with this sort of code:
Code:
data ="iTemp=" + iTemp + "&oTemp=" + oTemp + "&lLevel=" + lLevel + "&wDoor=" + wDoor + "&cDoor=" + cDoor + "&wLevel=" + wLevel + "&wPump=" + wPump + "&rBarrel=" + rBarrel + "&vFan=" + vFan + "&hLamp=" + hLamp
You can not simply add a constand string and an integer or any other variable like that.
Look at my code and see how to place formatted data into a char buffer.

____
Paul
10  Using Arduino / Networking, Protocols, and Devices / Re: Parsing, Converting, and Storing Data from a Modbus TCP Response on: September 22, 2014, 09:06:09 pm
I made a quick example using the Mubus library.
It is untested as I don't have a Midnitesolar controller and in my setup, my Arduino is the slave unit, not the master.
You will need to set the IP to the correct IP address of the Midnite unit and any other router settings as well.

If you are connecting a computer directly to the Midnite controller, check if you need a cross-over UTP cable or if it will auto-switch the tx and rx lines. Otherwise go through a router.

It is setup for all the registers you asked, but only prints out the first register to the serial port.
I looked at the PDF and at their awful mixed up internal register allocation.

You can grab the code from my dropbox https://www.dropbox.com/s/a6g1h4n0au55sd0/Mudbus-example.cpp?dl=0

If you are using the Arduino IDE, you may need to change the file extension from .cpp to .ino I think. ( I don't use the Ardunio IDE)

Do you have further ideas of what you would like to do with this infomation you can get from the solar controller?
____
Paul
11  Using Arduino / Networking, Protocols, and Devices / Re: Parsing, Converting, and Storing Data from a Modbus TCP Response on: September 19, 2014, 06:15:45 pm
Any device that uses the Modbus protocol will need to be communicated using the Modbus protocol, regardless if you use TCP or RTU modes for effective data exchange..

I don't see in your code any use of a Modbus protocol library, though you appear to write characters out the Ethernet port that might look like a formed Modbus register request packet (which I haven't checked)?

For Modbus TCP, look at using the Mudbus library, https://gitorious.org/mudbus

For RTU, look at the Simple ModBus Master library.
You will find a thread on the later within this forum section, http://forum.arduino.cc/index.php?topic=176142.msg1886727#new

It might be worth while reading up a little on how data is reprsented when using Modbus. For example, data is transferred as 16 bit intergers, then it is up to you how that data is then used, whether it is a bit packed word or whether the data is stored as a float using 2 Modbus registers, hence 4 bytes.

Just to let you know, I'm using Mudbus in my Ether-Mega to communicate Modbus TCP back to my GNU/Linux system for my micro-hydro turbine and solar installation here at home.
____
Paul
12  Using Arduino / Networking, Protocols, and Devices / Re: Help with ModBus RTU Master-Slave: SimpleModbus [SOLVED] on: September 18, 2014, 07:45:26 am
Hi Haxan,
You ask:
Quote
My question now is: Will it be possible to port the code for the master side on to Raspberry PI ?
I want to install a webserver on Raspberry Pi and send the command from browser. Any pointers?

I would suggest you take a look at libmodbus which you should be able to install and use right away.

I have done this myself recently and am actively developing an application that is developed in C and runs on Linux.
Some details that might interest you, my system  consists of:
Debian GNU/Linux runing on small DELL D420 laptop, soon to be migrated my CubieBoard II (ARM CPU).
  • libmodbus to communicate to the Arduino or any Modbus device via RTU or TCP.
  • libmicrohttpd used to provide full HTTP web server functionality.
  • offers an API to handle specific HTTP requests such as user authentication and AJAX calls
  • scans connected Modbus devices and reads in or writes tags
  • scans tags for alarm conditions
  • scans tags to maintain basic stats
  • scans tags to maintain history log for charting
  • all configuration data held in files and read on start up
  • operates in a terminal screen as text mode using Ncurses library

Where my intention is leading is to continue to develop this into somewhat of a ModBus data concentrator, able to talk to multiple device on both RTU and TCP at the same time.

In RTU mode it can talk via USB, or RS-485 and handle a multi-drop network of devices.
All device ports operate in separate threads within the application to allow for smooth and un-interrupted communications across all channels.

I've had it working now for the past months and more needs to be done, but if there is interest in this appication I'll make it available. My plan was to have it available for open source. I'm in the proces of doing some documentation.

My hope is that it will be a SCADA system that allows your web browser to be the GUI.

I would be interested in any thoughts any people have.
____
Paul
13  Development / Other Software Development / Re: How to change rs-232 port mode to half-duplex? on: September 08, 2014, 07:37:13 am
tlstadnik wrote
Quote
Another device use RS-232 port this half-duplex port mode
Have you thought that all you should need do is code up your comms routine so that you don't send anything until you get a finished response back for the device.

Doing this will give you half duplex.
Remember you have control when you send data out the serial port.

I am assuming the device you are communicating to can only do half duplex, is this correct?
Also, I am assuming the device you are communicating with will only respond on Arduino commands and not at any random time, is this correct?

You need to be very clear and specific with your descriptions on how your equipment works and how you wish it to work, or everyone makes lots of assumptions.
____
Paul
14  Development / Other Software Development / Re: How to change rs-232 port mode to half-duplex? on: September 06, 2014, 08:53:26 pm
I interpret half duplex as communications in one direction only at any point in time, whether this is done on separate Tx and Rx wires or on the same wire pair.

As westfw pointed out, to have half duplex on a two wire system such as RS-232 you need to use some form of signalling to determine the direction of data. This can be done as part of a software protocol or by using additional signalling wires which are part of the RS-232 specification.

I think there are a few of use who remember years of old where we used half duplex radio modems, maybe even some of you remember using X25 on TNC's as part of our packet radio systems, all half duplex with and with a RS-232 connector on the modem to our old computers.
____
Paul
15  Topics / Home Automation and Networked Objects / Re: Safe way? on: September 06, 2014, 08:39:58 pm
Magnetman wrote:
Quote
This way, the worst that could happen is a tripped fuse

I'm pretty sure most would agree with me if I were to say
Quote
the worst that could happen is that you die or suffer a serious electrical shock

When will people acknowledge that, in most countries I know, working on household mains wiring requires you to be more than just familiar?

As a community we should be making this very clear, especially as in this case, it certainly appears to me that the OP is not familiar with mains potential and has no idea, granted he did ask about the safety aspect.

I might suggest we have something in our forum guidelines that highlights this in no uncertain terms.
Magnetman, will you be ready to answer the lawyers should something untoward happen to user someoneintheworld?

Yes you are correct in saying
Quote
With proper reseach\guidance everything can be done in a safe manner
but who will be there to know and check?

As Terry pointed out, using isolated and enclosed products might be worth you using.
____
Paul
Pages: [1] 2 3 ... 24