|
|
|
Heya Sam,
I currently have my SEGmeter serial i/o connected directly to the SEGbox router, as they're in the same location (in the same box).
Looking at playing with additional segbox's for remote monitoring/temp sensors etc. as well as a basic 16x2 LCD local display option and trying to work out how the soft_serial port works. either over xbees, or over wire, using MAX232s or similar to convert the TTL levels to RS232.
At the moment it appears that either the SEGmeter UART connects direct or via xbee, but not both? (or do they play happy together?) If I want to move into xbee comms, do I need to put one on the SEGmeter - or can that stay wired direct via the uart header?
I thinking about playing with another SEGmeter sitting close to the exisiting one, thought I might be able to connect via the soft-serial pins 2/3, as a way of hacking away without the original going offline too much, to try out adding additional global string messages or listening to them to display data locally.
Is the current code designed to listen to on the RX pin for xbee messages (AP/transparrent mode I'm guessing?) from other SEGboxes then mirror those messages back our the TX pin to get to the SEGBox?
There seems to be a bit of magic happening that I can't quite get my head around..
Alternatively if you start selling an inline single circuit kit with relay/temp etc i'm sure that'll answer most of my questions....
Thanks!
dargs001
|
|
|
|
Hey Simon,
I haven't had much luck with soft serial. The main problem is servicing the serial mirror buffer frequently enough during the full on sampling process. This means it overflows, and or misses a significant amount of data...
At the moment, the best solution for multiple nodes is the Zigbee, however there are some awesome things in the pipes with the mqtt work @geekscape has been doing lately. This is going to be very exciting for multiple node environments.
We have also started on some designs for other interesting things, one of which is a smart plug mote type thing, which at this stage is targeting a Zigbee network.
Thanks,
Sam.
|
|
|
|
Hi Sam
I have been playing with NewSoftSerial lately to try to get a serial LCD display working. Only limited success consistent with your remarks above. Do I understand it correctly that the problem is to do with the NSS library using interrupts and this conflicts with the hardware uart interrupts?
I noticed that the variable MIRROR_FREQUENCY seems to be quite insensitive. Is it a frequency or an interval? I have tried it between 10 and 100 (default was 50) with little impact.
One thing I did have some imapct with was when I re-allocated the PIN_SERIAL_RX and PIN_SERIAL_TX from 0 and 1 to 9 and 10. I was going to send the output via serial/usb to a comms program like hyperteminal to see if this got around the interrupt problem. The data loss was still too high but the surprise was that the router starting getting data points every 1 hr 20 mins compared with about 11 hours previously. Note that the only change made was in software. I had not changed the router connections to pins 9 & 10. This was rather unexpected to say the least.
If this had worked I was intending to switch between 2 software uarts for the router data and the serialLCD data as in the TwoNSSTest sketch example.
I have read elsewhere that "Interrupt service routines should be kept short and fast. If your ISR
take more than one character time to execute, then you could lose
incoming characters.". I guess that means diving into the NSS library?
Anyone else had a play with NSS?
Regards
Rob
|
|
|
|
Hey Rob,
I was trying to daisy chain SEGmeter, with the recieving of data on NSS to be then mirrored out the main serial interface. This was the issue I had, with the device being able to listen often enough and pull the buffer before losing data to be mirrored.
Sending data from say NSS to an LCD should be just fine, as you can send it whenever is convenient, in fact this is probably a pretty good answer if you don't want to go the normal LCD route?
@samotage
|
|
|
|
Sam
It seems like a great way to go as serial only requires + & - plus the Tx data so only three wires to the board. So far the answer is being elusive with the LCD updating only every 3 minutes and the router getting data only every 86 minutes!
So you are saying that with only sending data to the second serial device there should be no issues with interrupts? I am not trying to receive any serial data.
Some more info: when serial data is passing to the LCD the rest of the program stops running - the status LED does not blink and no data goes to the router for the 86 minutes.
Thanks
Rob
|
|
|
|
Hey Rob,
Sounds like something is borking out in the call to your LCD blocking the whole shebams for the 86 minutes. Do you have a sample of the codes you are using?
Another thing to try, which often works for me is a simple simple sketch with it Serial.println some stuff, or a LED blinking, then craft your LCD call here. When it's all going well, then splice it into the SEGmeter sketch.
@samotage
|
|
|
|
Hi Sam
I agree with your assessment with something blocking the rest of the code. The status LED not flashing is a good indicator of that. I have the 86 minutes down to 33 by changing the MIRROR_FREQUENCY to 400. So the code seems to be responding to some adjustment but I have a niggling thought that there is some interrupt issue.
Rob
|
|
|
|
Some pretty strange things seem to happen with soft serial comms. After a couple of days of running with the 33 minutes interval between data points going to the seg server, the device changed modes of its own accord and started sending data every 40 - 50 seconds. This is as it was prior to adding the serial LCD.
This makes it fairly unsatisfactory because as soon as I make any other minor correction to code it goes back to 33 or 86 minutes or whatever it feels like. Makes troubleshooting quite difficult.
Rob
|
|
|
|
The Arduino Mega 2560 is "The Mega is compatible with most shields designed for the Arduino Duemilanove or Diecimila." Does this offer an option for Segmeter since it has 4 hardware uarts?
Rob
|
|
|
|
Hey Rob,
Though I've used a lot of 1280 megas, namely for their 16 channels of ADC, I've nerver investigated the multiple uarts...
This could be win? Who knows?
Sam.
|
|
|
|
Still waiting on the 2560 to arrive so I persisted with examining the sketch for improvements. I found that the serial handler was started in six different places through the code to compensate for the small buffer for receiving serial data. Because I am only wanting to send serial data to the LCD I didn't need this so turned five of them off. This gave me almost what I was looking for with 30 second or so updates of the LCD data and updates to the router every 130 - 150 seconds for power data.
In addition to the code changes, the parameters I am using after playing around were as follows:
CYCLES 5 //was 18
MIRROR_FREQUENCY 300 //was 50
The lines I have commented out look like
serialMirrorHandler();
Also used a delay before starting the serial data flow to the LCD:-
if (millis() > 200000) {
serialMirrorHandler();
}
The only drawback is that every now and again the LCD is sent all zeroes but I think that is when data is sent at the same instant to the router and the interrupts must take over.
Apart from this I think I can say that serial LCD is working successfully.
I find that it is of great advantage having a continuous display ( I am displaying power used, solar generated and lights circuit) as you can keep a close eye on usage if you wish and find out what is on and if it can be turned off.
Rob
|