New IT forum
26 June 2022, 06:09:42 pm *
Welcome, %1$s. Please login or register.

: CubieBoard 2 and Cubietruck both now in stock.
 
Pages: [1]

Author Topic: RS-485  (Read 10254 times)

Kevin

  • Newbie
  • *
  • Posts: 17
RS-485
« on: 19 February 2012, 09:33:54 am »

I have a need to connect my DreamPlug to some RS-485 devices.  Has anyone succeeded in doing this?

My plan would be to do it via the UART with an RS-232-to-RS-485 adapter.  Can anyone recommend one?
Or maybe there's a better solution?
Logged

Grinch

  • Newbie
  • *
  • Posts: 44
Re: RS-485
« Reply #1 on: 21 February 2012, 07:21:03 am »

Just my 2cent's, I'm not a expert but from I've see the RS232 port should be only for debugging purpose with the JTAG module, may be you can try with a USB-RS232 converter and then from the serial side of the converter try to emulate the RS485 or more simply use a little external microcontroller like a PIC with the slave USB feature and then use the RS232 port of this microcontroller to implement a true RS485 port by using e.g. a DS75176B driver (http://www.ti.com/lit/ds/symlink/ds75176b.pdf), in other word use the external microcontroller to be a USB-RS485 bridge.

I'm not a expert of the DreamPlug, just a noob at this time, may be some other skilled people can suggest a best way to solve your question.

All the best
The Grinch
« Last Edit: 21 February 2012, 08:50:06 am by Grinch »
Logged

tBergmueller

  • Newbie
  • *
  • Posts: 4
Re: RS-485
« Reply #2 on: 06 April 2012, 06:23:10 pm »

Have you succeeded with RS485? I'm currently developing an RS485 application and I'll use FTDI USB to Serial converter. I think in a week or two I could give more detailed information whether it works or not, currently I'm stuck in getting Mono framework to work on Dreamplug because I've built a pretty large .NET-dll for RS485 communication and I really don't wanna write all these classes again  ;D

~edit~
j.f.i: Compiling Mono 2.6 for Ubuntu 9.04 on Dreamplug suceeded, but there are problems with Console.Readline() and Console.ReadKey()... but that seems to be a missing link btw. Mono Readline and GNU Readline..
« Last Edit: 06 April 2012, 09:19:36 pm by tBergmueller »
Logged

dacarys

  • Newbie
  • *
  • Posts: 1
Re: RS-485
« Reply #3 on: 01 July 2012, 02:13:27 am »

Anyone get this working?  I'm trying to work up a proof of concept for my company.  I am new to the DreamPlug so not sure the best approach.

I am thinking of using this: http://www.cti-shop.com/en/RS485-converter/USB-Nano-485.  Do you think something like this might allow my software to talk to a sensor device using ModBus over RS485?

Your input is very appreciated.

thanks,
Logged

Grinch

  • Newbie
  • *
  • Posts: 44
Re: RS-485
« Reply #4 on: 03 July 2012, 07:43:17 am »

Have you succeeded with RS485? I'm currently developing an RS485 application and I'll use FTDI USB to Serial converter. I think in a week or two I could give more detailed information whether it works or not, currently I'm stuck in getting Mono framework to work on Dreamplug because I've built a pretty large .NET-dll for RS485 communication and I really don't wanna write all these classes again  ;D

~edit~
j.f.i: Compiling Mono 2.6 for Ubuntu 9.04 on Dreamplug suceeded, but there are problems with Console.Readline() and Console.ReadKey()... but that seems to be a missing link btw. Mono Readline and GNU Readline..

@tBergmueller
Do you've succeeded with Mono? I've to use the Dreamplug to command a machine and then I've also the problem to set up a user interface. Due to the absence of a GUI into the Dreamplug, is mainly a command line distro, I'm thinking to set up a gui trough a dynamical web page coded e.g. in PHP. At this point I've some trouble and then how I can make a interaction from the user and my application that have to command e.g. motor and other devices? In my mind if the user press a button some action have to be performed on the external devices attached to the USB bus of the Dreamplug but also into same time the program have to be some other task e.g. make some measurement trough the external device and so on, then the web interface may be a workaround to the GUI less Linux OS.
Do you've some suggest regarding this type of approach? There are some other way which is best to use instead a web interface approach?

Thanks in advance and my

best regards
Grinch
Logged

tBergmueller

  • Newbie
  • *
  • Posts: 4
Re: RS-485
« Reply #5 on: 09 August 2012, 11:44:33 am »

Hi,

sorry for the very late response, yes I succeeded, please refer my blog (there are some entries on how to compile mono). I currently also have a package online but that's for my company and has the root password set accordingly, I may upload it with a different root password so everybody could use it.
http://www.semicolon-expected.blogspot.co.at/2012/04/dreamplug-debian-squeeze-mono-20.html

To your second issue; check with Webserver and CGI or - which I'd prefer - go via Tomcat Server (Java Servlets) or Java Serverpages and JNI to get appropriate low level functions.

You could also - what I used to do - create a MySQL-Database where the Webapplication (PHP) is writing messages to and a more native Application, the one that controls your motors, gets notified (or polls the DB) then and processes these messages accordingly to your user interactions.



« Last Edit: 09 August 2012, 11:47:04 am by tBergmueller »
Logged

tBergmueller

  • Newbie
  • *
  • Posts: 4
Re: RS-485
« Reply #6 on: 09 August 2012, 11:46:14 am »

@dacarys Yes, got this working, now mono, FTDI-USB-Devices (as /dev/ttyUSBn), apache2 and some other stuff is running reliably in a bigger project with somewhat 50 dreamplugs as controller units.
Logged

Grinch

  • Newbie
  • *
  • Posts: 44
Re: RS-485
« Reply #7 on: 10 August 2012, 10:30:46 am »

Hi,

sorry for the very late response, yes I succeeded, please refer my blog (there are some entries on how to compile mono). I currently also have a package online but that's for my company and has the root password set accordingly, I may upload it with a different root password so everybody could use it.
http://www.semicolon-expected.blogspot.co.at/2012/04/dreamplug-debian-squeeze-mono-20.html

To your second issue; check with Webserver and CGI or - which I'd prefer - go via Tomcat Server (Java Servlets) or Java Serverpages and JNI to get appropriate low level functions.

You could also - what I used to do - create a MySQL-Database where the Webapplication (PHP) is writing messages to and a more native Application, the one that controls your motors, gets notified (or polls the DB) then and processes these messages accordingly to your user interactions.


Thank you for your suggest,
in the meantime I've read and evaluated several way to accomplish my task and finally I'm going to check this solution:

- C/C++ application running on Dreamplug with a TCP-IP socket support. I'm thinking to create two thread, one is a listening server for incoming request and another one is a server for sending reply.
  Of course the server will be more simple because have to manage simple command from the user application (see next point) and reply to this one when the request was performed by the Dreamplug.
- Java PC application used to control remotely the Dreamplug trough the web socket programming.

The behaviour should be that the Java application is a simple GUI and every time the user push a button or make some other action on the GUI the application trough a socket send the request to the listeing server executed as a single thread into the C/C++ program on the Dreamplug. When the action is performed, like running a motor, the Dreamplug send back to the Java application resident on the user site the reply like "motor-on" trough another socket, at this point the reply is processed and then I can blink a led on the GUI and show the motor button into the pressed state. From this perspective the Java is a simple GUI that reflect the state of the Dreamplug. In other word because the Dreamplug itself can't run any GUI I will re-create it remotely trough this mechanism of a simple command-response protocol.

With this approach I think I can not penalize the performance of Dreamplug because I'm avoiding to run graphical server pages (like Javascript applet, AJAX or similar technologies), Dreamplug have just to run a C/C++ application in background and wait for incoming connection trough some sockets.

Meke sense for you?

Now I've another question, how to code the Dreamplug applicatin in order to make it not blocking for other Dreamplug system task? In other word I like to run the main code like a service, in this way when the C/C++ main program is running I can also connect the Dreamplug trough the standard lighttpd web server and then make some FTP upload and download of file and data by means of some simple PHP pages (e.g. to make software update, upload and download file to and from the Dreamplug). From this point of view may be I've to code the main app like a service but I'm unsure if this is the right way.
Also I like to have full access trough the command bash of the DreamPlug also when the main program is running in order to have direct access to the internal file and so on then this seems to me that I've to code my program as a service but I need some other infos from expert, I'm a noob of the Dreamplug.

Could you also gimme some help on this last point?

Thanks in advance!!

Best regards
Grinch
Logged

tBergmueller

  • Newbie
  • *
  • Posts: 4
Re: RS-485
« Reply #8 on: 15 August 2012, 07:34:59 pm »

Hi,

probably someone could split this thread as the last two responses have nothing to do with RS485 ;)

I'd not call myself an expert, but probably I can help you too.
You may code your application like any desktop application, because all the GUI stuff is not really dreamplug-specific. Then simply start your program (either in foreground or background (with & after calling via commandline)). Probably you want to run it - as you say - as a service which is called a deamon on dreamplug.

The dreamplug is running a more or less "normal" linux distribution, the ones purchased at NewIT either Ubuntu or Debian, so you have all the advantages of a normal operating system. Most important in your case is multitasking and prioritizing - so don't mind about parallelization, that's the Operating Systems task.

Just start all the applications you want in background (see if they are running with bash commands ps -A, jobs or top) and prioritize them with the "renice" command.

I'd recommend to dig into unix scheduling mechanism herem because the OS is responsible for all your parallelisation - you may code each application like it's running on its own dreamplug and don't care about the rest. Further I think it's a good idea to put some sleep() into your programs in case you are running infinite loops.

hope that helped or did O completely miss the point?




Logged
Pages: [1]
 
 

Powered by MySQL Powered by PHP SMF 2.0.10 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!