Installing on Raspberry PI with modbus serial
-
A little gem that I thought someone may find useful.
Hardware:
Raspberry PI 256MB Rev 2 (Overclocking to "dynamic turbo", and re-allocating the gpu memory helps speed up java a bit.)
Digital to Serial converter 3.3 / 5V to RS232 (from ebay [http://goo.gl/sjdzN])
Ablerex 60Amp MPPT Charge controller
Custom made Serial Cable( 1<->4, 2<->3, 3<->2, 4<->1&6, 5<->5, 6<->4, 7<->8, 8<->7, 9<->9)The Installation packages used:
ma-full-core-2.0.3
m2m2-modbus-1.4.1
m2m2-scripting-1.0.0
jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012
librxtxSerial-2.2pre1After doing the installation and getting everything working, the serial port drop down list in Mango remains empty.
After trying all sorts of tricks, the only one that managed to get the problem resolved is creating a symbolic link to the serial port. (Clearly, the rxtx library is expecting a certain naming for the serial ports)
sudo ln -s /dev/ttyAMA0 /dev/ttyS0
chown root:dialout /dev/ttyS0 -
Thanks very much for this, I'm sure others will find if useful.
Joel.
-
It seems to me that a few months ago I did a similar trick :)
I did not know then about the "dynamic turbo" and Mango worked very slowly. Can you tell us about the performance? Do you use it normally, without major problems?
Regards,
Mat -
I've been thinking of doing a minimal Mango installation on a raspi as well. If it works I can shut down my 24/7desktop and save some electricity.
What OS version are you using? Is it all running off the SD card? Please describe your setup a little more......please!
The Raspi is an amazing little device for 35 bucks. Currently using one as a media center with Raspbmc and it's working pretty well.
Thanks,
Mike
-
The Performance of mango on the PI is slow. Each page accessed from the Pi takes a while to render (6 seconds to show page, and another 9 seconds to render the graph, when clicking on a data point). I am sure that the 512Mb Pi should be more responsive.
The Linux performance:
up 7 days, 5:40, 1 user, load average: 0.26, 0.25, 0.21The Mango java process:
VIRT RES SHR %CPU %MEM TIME+ COMMAND
226m 144m 3524 11.5 78.1 228:50.24 javaMy goal was data acquisition, and reporting. To access the data once a day, and to receive an email report daily works perfectly. So the tardy access is acceptable for me. The data gets retrieved every 5 seconds, which is more than enough data for me. I get emailed with the day's power, and I can log in and view detailed information for the day, albeit slowly. It has run continuously for the last week with absolutely no issues so far. I have only had to restart mango after accessing it from to many IP addresses (Using no-ip.com and port forwarding to access this from outside, I have been showing it off to everyone!) Costs versus functionality, It is incredibly awesome! With a relatively simple setup, I have a lot of information available. Though I am still trying to figure out how to get the AH and work out the currently available power, though this will only be possible if the outgoing current is also being monitored (I am still working on this)
The pi mainboard is standard. The Power is taken directly from the main batteries with an adjustable 1.5 to 30V 3A Converter / LED Driver Charger circuit purchased from ebay. (http://goo.gl/Xzhlm) This I had adjusted to exactly 5.0 Volts out, then cut one of the micro usb cables (cut off the big square USB plug) and soldered it onto that board to connect it to the pi. The other side of the power board I soldered cables to eyelets, and connected it directly to the main battery terminals. Very efficient, regulated 3A power for the Pi. And still runs even if the mains inverter is off. The SD card, also from ebay, was the cheapest class 10 card I could find. The Raspberry image was the stock standard one from the Pi Site. The Casing for the Pi is the one from Farnell (The only gripe with this is that it has no slot to access the GPIO) I used a hacksaw to cut a square out on the one side of the Pi casing to plug in the serial cable to the serial port mounted inside the casing, which is kept in place with double sided tape (Though, its not necessary as the serial port rests snugly against the S2 connecter on the main board when the casing is closed and cannot move). I am still trying to source an affordable Pi case with a serial port opening. I am not happy with the current horrible hack even though it is not immediately apparent. The Pi connects to my home network via wireless (Cheapest usb wireless N card I could find on ebay) I have left the unit headless (No screen or keyboard) and modified the (/etc/wpa_supplicant/wpa_supplicant.conf) to always give a fixed ip address.
-----------------------------------------------------------
edit: /etc/wpa_supplicant/wpa_supplicant.conf
-----------------------------------------------------------
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1network={
ssid="CYBERHOME"
psk="myveryunsecurepassword"
proto=RSN
key_mgmt=WPA-PSK
pairwise=TKIP
auth_alg=OPEN
}-----------------------------------------------------------
edit: /etc/network/interfaces
-----------------------------------------------------------
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.confiface default inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1The Charge controller I am using is the 40A, 60A (12/24/36/48V) from mppsolar (http://goo.gl/TQZkF) The other ones even though they have awesome futures do not have the communication interfaces.
The Inverter I am using is an off grid 3KW / 6KW from the same company. Solar panels are 2 x 240 Watts Sharp Panels. (I live in an apartment, and I am still trying to figure a way to put up another two panels without going over the small allocated space on the cluttered roof, and still get sun)
4 x 80Ah (Sunlight SP12-80 AGM) 5 x 26Ah (Sunlight SP12-26)- The final goal is to have 10 x Sp12-80's only. (I am in the process of building a square steel tubing rack for this, I helped a friend make a pilot one this weekend and it works great) The Royals, and other non sealed lead acid batteries are not usable inside an apartment. Gassing and acid is a really big issue.
My next step is to control the mains relay isolators on / off depending on the available and incoming power, and to finally switch the inverter on / off if needed (it has a remote switch). I am hoping to do thus all through Mango. I know that Mango can do it, I still just have to figure out how.
To a get a better performing machine, which is my next project, once I get this system working the way I want it to, is the use ODROID devices. (http://goo.gl/SWO8C), (http://goo.gl/6cShf), (the second one includes GIO controls as well). They have quad core processors and similar, but much better specs than the pi, though the one with GPIO is about 130$ which is a lot more than the Pi, but a lot less than a laptop or PC, and it has some very decent specs. The smaller one is about 89$ with some very good hardware.
I think an alternative is to use mango on the Pi simply as a data logger, and run mango on a normal machine to process the data once a week. Best of both worlds. Guys at infiniteautomation, is this doable? Either way, Mango makes data collection very simple, and works very well.
Pi Hardware summary:
1 x Raspberry Pi 35$ (40 Euro from local Farnell)
1 x Pi Casing 15$ (Also Farnell)
1 x Serial Port 3$ (ebay)
1 x DC Converter 3$ (ebay)
1 x USB Serial cable 1$ (ebay)
1 x 16GB Class 10 SD 11$ (ebay)
1 x Wireless N Wifi USB 4$ (ebay)
2 x RS232 Serial plugs 6$ (Farnell)
Total 78$Sorry about the long winded answer... I hope I have covered everything. If there is any more information needed, please give me specifics, and I will answer what I can. I am also open to any suggestions and advice.
-
Excellent write up, thanks for all the details. I do have a few comments that mights be useful. I know you are using the free version but DGLux offers a lot of performance improvements for this type of application. It's a client side technology so is very light on the Mango server processor. It can also pull in raw data like an accumulating kWh value and do calculations on the fly to figure out hourly, days or other types of usage.
If you are interested in doing some beta testing and reporting back you can try out the new version of Mango core 2.0.5. It's not ready for full release but it has several improvements for low power devices including the jsp pages being pre-compiled so they will load faster on the initial page view. It's been tested with good results on more powerful ARM computers but would be interesting to know what your experience would be with the pi. You can get the new version here: http://store.infiniteautomation.com/core There is also a new version of DGLux with some performance enhancements that you can try if you are interested. http://store.infiniteautomation.com/module/dglux
The other idea you had which is a good one is to use Mango on a pi to collect the data and then stream it to another instance of mango possibly even a cloud version of Mango. This would work well for pure monitoring applications. There are also ways to have it be two way communication. You can look at the HTTP module or the Persistent TCP.
Joel.
-
@Joel,
Awesome, thank you. I Have downloaded that, and I will test this out during this week, as time permits.
Just another point that I forgot, which just showed up on this download. I had to edit the ma-start.sh file to remove the -server option from the java startup (Line 45). When that option is included, the startup script fails with:
Error occurred during initialization of VM
Server VM is only supported on ARMv7+ VFPWhen that option is removed it runs on the Pi. That probably also has an impact on the performance.
This Beta version has so far started up with no problems. (After removing the -server option)
-
Thanks for the great information. I'm going to have to get around to trying this on my 512 Pi. Right now I have it streaming 1080 video from my NAS with no issues at all using Raspbmc. Some folks with the 256 version have issues streaming so you may be correct with your assessment of memory and performance of Mango. Also as you pointed out, voltage supply to the Pi is critical to good performance. Many people without meters are astonished to see their "5V supply" is running much less, especially under load.
I am amazed you are doing all this in an apartment! Good job.
I have the Pi case from Sparkfun in the US. It has the opening for the GPIO pins and is a good cheap case. I must be available on your side of the pond.
Too many projects and ideas floating around in my head and garage...........
Mike