-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test changing brush interval #3
Comments
I tested the new GetValues.ino on all three of my sensors, purchased in April 2017:
Good news is that all give believable values and the brushes (for Y511 & Y514) activate with the "Activate Brush" command. The bad news is that for both Y511 & Y514, none of the other functions work. I played around with the "Waiting for sensor and adapter to be ready" delay (line 77 in sketch). Increasing from the original 0.5 sec to 1.3 sec was necessary to get Y520 to work, as expected, but increasing up to 50 sec had no affect on getting responses for Y511 & Y514. See example output below. Note 1: The sketch returns a "Failed to activate brush!" error, but the brush actually does move exactly when the "Activating brush" command writes to the serial monitor. Note 2: For Y514 their appears to be a ~10 sec delay from the first result value before a real value is transmitted. Because that chlorophyl sensor emits a blue light each time a measurement is made, it's clear to see that no lights are emitting in this time. I'm wondering if there is some kind of automatic delay after a brush is activated. @SRGDamia1, any ideas?
|
I'm sorry. It worked fine on my Y511 except for the brushing command. If the chlorophyll sensor failed to start measuring, then I'm not surprised you're not seeing the light go on. Are you sure you have your sensor slave ID/address right? Can you see the sensor reply with the "GetSlaveID" utility sketch? Try turning on the debugging and reprinting the output with all of the commands and responses printed out. (Uncomment line 61 "sensor.setDebugStream(&Serial);") Then you can try hooking the sensor to your computer and sending the commands through Simply Modbus Master. That will also show you if the sensor is responding by the response isn't being parsed correctly or if there is no response at all. You could also try to increase the values for "modbusTimeout" and "modbusFrameTimeout" at the very bottom of YosemitechModbus.h to see if that helps. The modbusFrameTimeout length is defined by the modbus protocol and should be correct, but the time it takes the sensor to respond (modbusTimeout (500ms)) might be inconsistent between the sensors. I think in my tests it was 300-400ms for my sensors, but maybe 500 isn't a big enough buffer. My last suggestion would be change the "stream->read();" in the "emptyResponseBuffer" function with something like "char c = stream->read(); _debugStream->print(c);" to see if somehow data is getting dumped out of the buffer at the end of the timeouts. |
@SRGDamia1, thanks for your ideas. I did use the "GetSlaveID" utility sketch (forgot to mention it), which returned the SlaveID but not the sensor serial number for the Y511 & Y514 sensors (but it returned both for the Y520 sensor). I'll work on trying some of your other ideas this afternoon. |
Update, after substantial changes to this library, especially it's dependence since Sep. 6, 2017 on the new EnviroDIY SensorModbusMaster library. When trying the current and much revised GetValues example sketch and the GetSlaveID utility sketch on the Y520 Conductivity, Y511 Turbidity & Y514 Chlorophyl sensors, I have continued to have challenges:
Below is the results I get from running this code:
|
Are you definitely able to change the brushing rate using a computer or some other modbus controller [not using this library or SensorModbusMaster]? If you can control the brush from a computer but not this library, it could be an issue with this library. Otherwise, it is your sensors that are the problem. |
I just finished using the USB-to-RS485 converter and the Modbus Runner 1.9.1.3 desktop software (for Windows) that Yosemitech provided. I was able to get all my sensors to respond to all commands, including Set SlaveID and Activate Brush. However, I am still not able to Set SlaveID with the following AltSoftSerial sketch, a 9V power source (https://www.pololu.com/product/2116) and the SCM TTL to RS485 Adapter 485 to Serial Port UART Level Converter Module 3.3V 5V (https://www.amazon.com/gp/product/B010723BCE/). This is my response.
It therefore looks like it's a software library issue. It would be great for you to try to retest. |
I'm sorry, I finally go a chance to run the sketch with my own Y511B sensor and found it didn't work. I didn't think I' would actually publish something on GitHub knowing id didn't work, so I dug through my emails and found this from Zoe at Yosemitech:
|
Here's another GetValues output from an older turbidity sensor. Note that extra character in the output form the Serial Number.
Verbose debugging output:
|
Here's output from the same sensor when running commands using YosemiTech's Modbus Runner v1.9.1.3 program: GetSlaveID: (Answer = 03)
SetSlaveID: (Answer = 01)
|
Here's the results from the ChangeSlaveID_AltSoftSerial.ino (changing from 03 to 01), with debugging on.
|
Here's output from the same sensor when running other commands using YosemiTech's Modbus Runner v1.9.1.3 program: GetSN (Answer = YL2917050209)
GetVersion (Answer = hw 1.3,sw 2.1)
GetKB (user coefficients, answers K=1.000000, B=0.000000)
SetKB (user coefficients, answers K=1.000000, B=0.000000)
ActivateBrush
GetBrushInterval (Answer = 30)
SetBrushInterval (set to = 60)
SetBrushInterval (set to = 30)
Activate Sensor (for DO+Tur+Chl+COD)
GetValues (for DO+Tur+Chl+COD), 5 times:
Answers
|
I think I've fixed things now. Please try updating SensorModbusMaster and this and running again. |
Will do! Thank you! I'll let you know what I find! |
Also, please check and see if it fixes #2 |
Bummer! I didn't work. My output is identical to what I got above (see #3 (comment)). In other words, it is still sending the 0x06 command to write to a single register. |
Did you update SensorModbusMaster? Can you check the version numbers of both? It's definitely using the 0x10 command and changing the address for me. |
Are you using PlatformIO or the Arduino IDE? If PlatformIO, check if you have both libraries installed by git or by library name/number. If they are installed by library name/number in PlatformIO, the web crawler that updates its indices only runs every day or so so you won't catch the update until it's run. Make sure you don't have the same library twice. I'll update the zip in the libraries directory. |
It worked!
It was my mistake. I had properly updated SensorModbusMaster to v0.6.2 but didn't notice that you also made changes to YosemitechModbus. Updating that to Master did the trick! |
Here are the results (with debugging output) from GetValues_Y511_AltSoftSerial.ino.
However, the Activate Brush command did not get the brush to spin, as I can do using the Modbus Runner v1.9.1.3 program.
|
I don't understand why the brush doesn't activate. The Send request and the Get response are identical between the GetValues_Y511_AltSoftSerial.ino and the Modbus Runner v1.9.1.3 program The manual does specify a 20s delay after activating the brush, before starting measurements, but it seems I can do both simultaneously using the Modbus Runner v1.9.1.3 program, so that's not a hardware or firmware constraint. BTW, the GetValues_Y511_AltSoftSerial.ino also fails to produce a Get or Set Brush Interval command. I can change these with the Modbus Runner v1.9.1.3 program, but GetValues_Y511_AltSoftSerial.ino actually seems to reset the brush interval to 30 minutes before reading the actual interval (i.e. I set the brush interval to 3 minutes with ModbusRunner, but my INO still reads 30, then I check with ModbusRunner and it now reads 30, even when the INO was trying to set it to 3 minutes). BTW2, I'm still doing all my compiling and uploading using the Arduino IDE. |
Really? It didn't activate? The command sent to the sensor was identical and it responded as if it did in the output you posted. From what you posted with the modbus Runner:
From your output above with the Mayfly:
|
I'm sorry. I'm kind of lost. From what I can see in what you've posted, this Yosemitech library is sending an identical command as Modbus Runner and the Modbus response from the sensor is also identical. Can you try creating a sketch just to test the brush activation. Maybe it has something to do with how long it has been since the brush was previously activated.. |
Yup. Thats right that the "Yosemitech library is sending an identical command as Modbus Runner and the Modbus response from the sensor is also identical." However, the brush doesn't actually spin when we use the YosemiTech library, but it does when we use Modbus Runner. It's very perplexing. I'll try your suggestion, to create a sketch just to test the brush. However, the response to the Activate Brush command from Modbus Runner is immediate and never fails, so I'm suspecting something else is going on. One thing to note is that the USB-RS485 adapter that I use with Modbus Runner supplies 5V power, while I've set up the SCM TTL-RS485 converter with a 9V step-up boost (which was recommended by @s-hicks2) from the Mayfly's 5V line. Its still perplexing to me that 5V always works from the USB-RS485 adapter, whereas I needed to boost to >6V to get the sensors with brushes to respond from the Mayfly (see #3 (comment)). |
I reached out last night for help & ideas from YosemiTech with this email:
I got this response from Wenxing Gao wenxing@yosemitech.com (@ZoeWXGao):
|
Success! I am able to manually Activate the Brush, using the same code I've been using (https://github.com/EnviroDIY/YosemitechModbus/tree/AnthonyTest/examples/GetValues_Y511_AltSoftSerial). The solution did not require increasing the voltage, as suggested by Wenxing Gao (#3 (comment)). The solution was to change my interface hardware. I switched:
The wiring harness worked for triggering Activate brush for any voltage from 5.0V to 12.0V! So, the question for me to figure out is whether:
|
Great! I'm going to close this issue then. I actually just fried one of my RS485 adapters... |
Yikes, how did you fry your RS485 adapter? Which one did you fry? It would be good to know what voltages these various devices can handle. |
I think it was one of the SCM boards.. I sort-of fried the Mayfly it was attached to, too. I accidentally plugged the pin that should have been attached to ground to 5V while the 3.3V was already plugged into the adapter. Everything got very hot and started responding very weirdly. I'm just really glad I didn't also fry my sensors. |
Wenxing Gao wenxing@yosemitech.com now has a GitHub account. |
Old sensors versions, including those that Sara has, did not support "Activate Brush", "Get Brush Interval", "Set Brush Interval" commands.
In the old sensor versions, the brush spins 3x one way and 1x the other way, as soon as the sensor gets power. It takes 10-11 sec to do. It will repeat every 30 minutes.
In the new sensor versions, the brush does not spin when the sensor is powered.
Look at code and notes in Get Values example sketch.
The text was updated successfully, but these errors were encountered: