| Author |
Message |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 19/02/2010 00:44:38
|
chrapchp
Initiate
Joined: 15/02/2010 16:36:35
Messages: 27
Offline
|
I am trying to figure out the easiest way to send a command once a day to trigger a time update on my arduino devices. I can manually do it and now I want to automate the write to a modbus register. I created a scheduled event via CRON and not sure how it can be used to trigger a softpoint to create a time stamp and write it to a setable modbus register.
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 19/02/2010 10:10:23
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1456
Offline
|
Check out event handlers. Find your scheduled event and then use a set point handler to set the value of your modbus point.
|
Best regards,
Matthew Lohbihler |
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 19/02/2010 15:48:45
|
chrapchp
Initiate
Joined: 15/02/2010 16:36:35
Messages: 27
Offline
|
What I ended up doing was setting a softpoint to contain the epoch in local time based on a CRON pattern. e.g. every 10 seconds. I can't think of another way to get the current timestamp to use in the event handler.
I used the schedule to fire once a day to feed an event to set the time into the given setpoint to be sent to the slave.
What I wanted was to use the softpoint to do it. e.g. CRON once a day, then set the the time for all slave devices. e.g. p.value = timestamp. Alas, this cannot be done at the softpoint level. It seems I have to create a schedule time event for each slave, then a event handler for each schedule event.
Another option is that I can change the arduino code to deal with slave ID of 0 and implement a broadcast write. Will Mango deal with broadcasts and if it does what doe it expect back?
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 22/02/2010 12:25:50
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1456
Offline
|
Modbus4J, the underlying modbus implementation, supports broadcasts, but not Mango itself.
|
Best regards,
Matthew Lohbihler |
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 27/02/2010 11:46:57
|
chrapchp
Initiate
Joined: 15/02/2010 16:36:35
Messages: 27
Offline
|
The Mango datapoint entry UI is set to accept a slave address of 1-240 so if I understand your reply, Mango cannot support modbus broadcast without changes to the application layer of Mango?
I suppose hack my ardiunos to take address 1 as a "broadcast" rather than the standard 0 address and hardcode only one device to send a response back.
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 10/03/2010 10:12:07
|
Andras
Initiate
Joined: 05/01/2010 15:54:00
Messages: 28
Location: Netherlands
Offline
|
@chrapchp - I was wondering what modbus library you use for your Arduino. I've been using this one:
http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave
It works OK to get data, but when I try to set data I get an error message. Probably the modbus command used isn't supported by the Arduino library. Looks like you use one that does.
(sorry for being a bit off-topic here)
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 10/03/2010 10:21:22
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1456
Offline
|
Update: the slave side of Modbus4J supported broadcasts, but there were problems on the master side. The library has been updated to fully support broadcasts now. Changed code has been checked into the CVS repo.
|
Best regards,
Matthew Lohbihler |
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 10/03/2010 10:25:14
|
chrapchp
Initiate
Joined: 15/02/2010 16:36:35
Messages: 27
Offline
|
I used that one as well. It does not have a modbus function 6 which is what is sent out from Mango. I hacked a function 6 in the arduino and I can write to it now. It is not pretty and plan on create a class someday to abstract the communication layer.
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 12/03/2010 16:55:40
|
Andras
Initiate
Joined: 05/01/2010 15:54:00
Messages: 28
Location: Netherlands
Offline
|
OK, thanks for the tip. I also added function 6 and I can now set points too I also made the whole thing into a separated Arduino library (which was something that needed to be done anyway).
I also added code to make it easy to check which registers were changed by the master.
I'll ask jpmzometa if he wants to include the changes.
(Again, sorry for being off topic here)
This message was edited 1 time. Last update was at 12/03/2010 17:32:26
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 12/03/2010 19:49:41
|
chrapchp
Initiate
Joined: 15/02/2010 16:36:35
Messages: 27
Offline
|
Great. It is nice when progress is made.
I transfer write registers to separate variables. If I need feeback of a write I use seperate read registers. That way I know my embedded code is performing correctly.
I will be hacking a broadcast as well for my nightly time syncs. Slave ID of 0 is not allowed from the ui. I will pick one arduino to respond to an address 1 request while the others are passive and used that as my broadcast address.
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 01/03/2011 18:00:26
|
jose francisco
Initiate
Joined: 01/10/2010 07:30:14
Messages: 37
Offline
|
Hello.
How can I send time and date to all arduino slaves with mango and modbus rtu?
Is it possible?
Thanks
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 05/03/2011 22:12:43
|
chrapchp
Initiate
Joined: 15/02/2010 16:36:35
Messages: 27
Offline
|
You can't set the broadcast address of 0 on the mango UI. If you want to work with the existing code base, select another address say 1 as the "broadcast" address. Not sure what you have for modbus implementation on the arduino side but probably is minimalist and probably does not have broadcast handling capabilities. I am assuming you got what was floating around for free. I had to add modbus functions on the arduino side to do what I want. I did not do broadcast functionality but it should not be too hard to implement.
I would change the code to handle a "broadcast" address and have only one device respond to a request to the master and the others are passive listeners. That way only one entry is required on the Mango side along with a CRON event to trigger write the timestamp.
Otherwise you could probably use Mango events to fire off to write the date/time as a unix epoch timestamp or what ever format you want to send to registers in Modbus and manually configure a date/time point for each device. That would emulate a broadcast.
Not sure if that helps.
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 06/03/2011 02:59:34
|
jose francisco
Initiate
Joined: 01/10/2010 07:30:14
Messages: 37
Offline
|
I'm using this library in arduino.
http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave
It doesn't implement broadcast messages. I was talking with the writer but he is busy to add that feature.
He says that there is no reply from slaves for a broadcast message.
It's very interesting to add broadcasting to the library but my C++ knowledge isn't good enough.
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 06/03/2011 04:12:49
|
chrapchp
Initiate
Joined: 15/02/2010 16:36:35
Messages: 27
Offline
|
That is the one I used and modified on my own for my own consumption last year. Even if you add a broadcast in the arduino code, the UI on the Mango side won't let you add a broadcast address of 0. So elegant changes or a hacks needs to be made, hence my suggestions.
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 06/03/2011 12:25:23
|
jose francisco
Initiate
Joined: 01/10/2010 07:30:14
Messages: 37
Offline
|
The writer of the library told me to make myself the changes and add them to the official release.
If you send the changes he will add them in the web page.
About Mango modifications... Is there any answer from Serotonin?
|
|
|
 |
|
|