Show Posts
Pages: [1] 2 3 ... 24
1  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
2  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
3  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
4  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
5  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
6  Community / Bar Sport / Re: Poll: sleeping time (ours, not Arduino's) on: August 31, 2014, 10:14:48 pm
Gosh Rob, looking from your photo, I could swear you don't look a day over 30  smiley-twist

I've tried to pull back on those long nights of design, where past 02h00 was the norm and getting up around 09h00 to 10h00 was seeing me miss most of the morning, and feeling sluggish.

I still feel like thirty in my brain, hopefully a bit more wiser, but I know I can't jump tall building in a single bound these days

At the moment bed is anywhere from 23h30 to 01h30 for me and wake up time is anything from 06h00 to 09h00.

Like Rob, I too don't have a job as such, I tinker and sometimes people pay me for having fun.

Life is good with a balance of nerdiness and getting outside and playing in the dirt.
____
Paul
7  Community / Gigs and Collaborations / Re: Arduino ethernet + sdcard+web interface on: July 31, 2014, 05:34:57 am
And even I get a pm asking for the code, any one else too?
Wow, I'm amazed, I didn't realise my programming skills were in such demand.
_____
Paul
8  Using Arduino / Displays / Re: 20x4 LCD - clear only a specific area on: June 14, 2014, 07:44:24 pm
A quick and easy example I have used which is fairly light on resouces.

Code:
lcd.setCursor(16, 2);
if (NVRAM.fanStarts < 1000) lcd.print(" ");
if (NVRAM.fanStarts < 100) lcd.print(" ");
if (NVRAM.fanStarts < 10) lcd.print(" ");
lcd.print(NVRAM.fanStarts);

You can see that I check for three conditions before printing the value, with each printing a space if true.
Change the condition range to suit your needs, or functionise it and pass the value to it.
____
Paul
9  Using Arduino / Displays / Re: [Solved] 20x4 lcd problem. (Spent 1.5 day) on: June 13, 2014, 10:25:02 pm
Arduino'eers,
It appears this thread has opened up a robust discussion about the use of oscilloscopes, logic analysers and the like, maybe that could have gone into its own long and exciting thread?

I won't like to take sides on this debate, but will like to say a little as I know the benefits of such equipment, having had my hand in electronics since a young boy building crystal sets and a few of the first micro-computer boards in the late 70's and early 80's possibly using micro-processors many of you won't even have seen.

What I can say, is that even though having fancy test equipment, I rarely found the need to use it, especially for digital projects, even including small development / production runs. My thinking is that such equipment for pure hobbyists is a definite nice to have and a sort of security blanket for when the times get really tough. Though I will suggest for hybrid systems, where you have analog and or a mix of analog and digital, you might be considered quite mad to develop 'blind', without access to such equipment. Conversely, if you are operating a business in this field, then it might look somewhat unprofessional not having such equipment.

A number of important points were raise in this thread, and the one I am hinting at is the need of good diagnostic skills.
How does one attain such skills?

There is no one right answer, but a keen desire to understand and learn and a strong determination to continue in the face of problems and failures I found to be a good value to hold. What is also needed is a degree of guidance, and this is the path I have taken with the OP behind the scenes.
Skype works quite well for this I find, living at different ends of this 'little blue dot' (C. Sagen).

Many of the points raised here by others I had gone through methodically with the OP.
Again there is a number of ways to start the diagnostic approach, with the way I choose in this instance, let's make sure we first have a correct development system and configuration.

Next was to confirm a visual on the OP's actual equipment, so I ask him for clear and detailed photos showing all parts concerned and the wiring used. After a few minutes finding another camera that was working for him, I received the photos, looking carefully over them, confirming his wiring was indeed correct for the use with a program I supplied him that I myself have proved.

So, at this point I knew he had a development system that would compile and upload to an Arduino, Eclipse IDE.
I also knew the program he has is fully functional, as I had developed it and proved it myself on identical setup, barring the source of the LCD manufacturer.
I confirmed a number of test points on the circuit with him, for correct voltages and that the contrast pot was wired correctly and set to a suitable position.
I asked that he use a UNO instead of the Mega, to prove there was no difference in result between the Mega and UNO or fault in either board he had.

After all this and still no progress I was then starting  to think, this is a dead LCD, which I said 'I do not believe', and so I thought it really could only come down to a bad connection. Even though from the photos I had, it all appeared to be ok.

But it wasn't.

It was 01h40 in the morning and I asked him to remove all wires that used slide on connectors and solder all wires to make a good connection.
I left him to it and returned this morning to find he had indeed found a problem with a connection point.
The problem was not a slide on wire connection, but a solder joint on the LCD board.
I then realised my flaw, I had assumed the LCD had arrived to him with the pin header already soldered, when it was not in reality.
This was the culprit, a poor solder joint of one pin on the LCD PCB made by the OP.

The OP was happy to finally see a LCD that displayed information and can now continue to proceed with his project.

I guess many will now see that clearing the bench and pulling out the big toys most probably would not have helped in the finding the problem.
It comes down to a lesson learned and one that many of us have made over the years, some too long ago to remember or care to remember.
I hope for the OP that he too will have learned a little more of what it is to become more skilled in electronics, which I dare say he has.

Again I am reminded not to make assumptions.

My methodology is to make no assumptions and to have very clear and concise information at hand.
Having clear and concise information is only going help solve the problem if you understand clearly and concisely this information, lest it be solved by trial and error or by chance.

One last thing I wish to say is that I have seen many times on this forum what appears to me as poor communications from people new to the field. Specifically, that when they strike a problem and ask for help here on this forum, often I notice the question is not clear or concise and leads many to making assumptions in their quest to help. It seems many only gain the skills of good communication after many years in the relevant field, in knowing how to pose their question in a way that is clear concise. While, sadly for many others, this skill never arrives.

I know 'beingobserver' has learnt from this exercise and am happy that he can now move to the next step of his project.
Hopefully he will become more 'beingobservant'  smiley-grin
____
Paul
10  Using Arduino / Networking, Protocols, and Devices / Re: Help with ModBus RTU Master-Slave: SimpleModbus [SOLVED] on: May 17, 2014, 06:37:19 pm
dvj215,
The only difference between the example in the library and the example in that 'Examples.rar' file is what has been discussed at quite some length here already, namley, the removal of the serial parity section in the instance configuration.

Like I said earlier, it would be worth your while to read this whole thread.
Then you will know and understand better what you needed to do.

So, again, for the sake of clarity, the original line to configure the instance in the SimpleModbusSlave code:
Code:
modbus_configure(9600, SERIAL_8N2, 1, 2, HOLDING_REGS_SIZE, holdingRegs);
And the modified line:
Code:
modbus_configure(9600, 1, 2, HOLDING_REGS_SIZE, holdingRegs);

That is the only difference between the two examples, look for yourself.
Of course you will need to make the appropriate changes in the library code as well, again, as has been discussed here in this thread quite clearly.

I am thinking people may only become confused with your post, saying 'The example in the library folder does not work' and with offering another place to download from.

This will be more so as you don't clearly state under what conditions you are using this library, for example, what version of the Arduino IDE are you using and for which board.
____
Paul
11  Using Arduino / Networking, Protocols, and Devices / Re: Help with ModBus RTU Master-Slave: SimpleModbus [SOLVED] on: May 12, 2014, 07:17:01 am
Hi JuanB,
I had a quick look at your links, thanks for them, I will continue with my own SCADA based on HTML5 and as a web application.

My idea is that I will use a small Linux board such as a Cubieboard-2 I have and continue to develop a combination of C/C++, Node.JS and Python based server, using web sockets for reasonably fast next to real-time viewing, especially from remote sites.

You can get some idea of some of what I will do at this link http://paulalting.com/hydrosolar/hydrosolar.php
It is my own home based renewable ernergy system, a combination of micro-hydro and solar.

Still a lot of work ahead, but progress is being made each day toward the sort of SCADA and control systems I would like in my more industrial systems.
____
Paul
12  Using Arduino / Networking, Protocols, and Devices / Re: Help with ModBus RTU Master-Slave: SimpleModbus [SOLVED] on: May 10, 2014, 06:15:07 am
 JuanB,
Just want to let you know I appreciate your fine work on making this library available.
I am using the Eclipse IDE with the Arduino 1.5.2 toolchain.

I downloaded the version 9 of Modbus Slave and have it seemingly working fine on a Ether Mega 2560 board.
I edited out the serial parity sections for it to compile correctly under the 1.5.2 toolchain.

Since I'm on Mac OSX and Linux I wanted to test it, so I downloaded a GUI based Modbus master program which will only operate under Windows unfortunately, this one http://www.protoconvert.com/SoftwareTools/Modbus/ModbusMasterSimulator.aspx

 So I ran that within VirtualBox which I have Windows XP and set up the COM port to be directed back to the USB port to which the Arduino Ether Mega (Freetronics) is connected to.
Well, blow me down, it works, albit with some time-outs  smiley-grin

I might even try making a small SCADA test using CitectSCADA I have on my XP image.
(My aim is to lessen my dependance expensive Allen Bradley Control/Compact Logix PLCs in my future projects, and to use start using Modbus with a mixture of Arduino based controllers together PLCs that can talk Modbus)

Next is to write some nice Python code to have my Cubieboard talk Modbus to serial1 on the Ether Mega.
Then the Cubieboard is my local server and link back to the outside world.

So, yes, your code works on Arduino Mega under 1.5.2 (Eclipse IDE), keep up the good work  smiley-grin
____
Paul (Tasmania)
13  Using Arduino / Networking, Protocols, and Devices / Re: Help with ModBus RTU Master-Slave: SimpleModbus [SOLVED] on: May 10, 2014, 05:49:43 am
dv215, you really need to read this thread before posting this questiong you have.
I am sure if you have read it you would have found your answer.
____
Paul
14  Community / Bar Sport / Re: Your latest purchase on: May 05, 2014, 06:48:26 pm
No need to be so modest Rob, I know that these 'new' tools are in fact the latest range for PCB and assembly.
I notice you got the funky porpose built SMD set, for very fine work, right?
I know you'll be using them soon on the new Quub boards that are currently being built.

But that first tool in your photo list, I'm unsure what that is used for and can only guess it is for bit banging, I know you like serial protocols, right?  smiley-mr-green
____
Paul
15  Topics / Home Automation and Networked Objects / Re: HELP! Greenhouse contol concept problems PLEASE READ! on: April 28, 2014, 06:31:22 am
lilrags16 wrote:
Quote
I am in an engeneing class
Me too, four years ago, I couldn't spell injuneer, and now I are one  smiley-evil

But seriously, like other have already said, sit yourself down and start putting together a functional description, you should at least know how to do that. Then, you will have a better idea of what your criteria and scope of your project will be.

All too often we hear the words of "Please Help", usually not even written properly.
____
Paul
Pages: [1] 2 3 ... 24