Hello dear programers I am trying to connect Avery weight G236 with PC over RS232.
But every time the weight retuns "insane".
">>6>>>\u0016\u0016\u0016>>6\u0016\u0016\u0016\u0016\u0016\u0016\u0016>\u0016\u0016\u0016>>"
My serial port configuration is (Baund rate 2400, Data bits 6, Stop bit two.). I tried to change these parameters but return was only "?" questioner or nothing.
Have someone any idea to solve this issue ?
I tried to solve issue related to scale serial-port comunication without any datasheet. It was random trying and configuring serial port in scale. Finally jdweng help my out. In coment wrote the most common settings for scales (my scale is Avery Weight-Tronix G236).
The normal default Baud Rate for a device is 9600, 8 bits, one stop bit.
On the end few informations about Avery Weight-Tronix scale settings:
How to show up menu ?
Hold PRINT button on the scale for few seconds
How to set serial-port comunication ?
Buttons SAMPLE = forward in menu, TARE - backward in menu, ZERO - confirm.
Try to find in settings menu mark SERIAL confirm with ZERO. In this submenu you can choose everithing related with serial-port comunication.
In my case (I couldn't find any manual from scale). I must choose broad which meanse the scale continuously sending weight to PC. It's not the best solution, but for my purpose it is enough.
Related
I am working on a C# development project which aims at controlling a flying robot thanks to a set of Optitrack cameras (infrared Motion capture system). The concept works really well, you get a position from the camera system, our application can access to these data and we can control the robot.
The problem comes, I believe, from the communication chain. We have a USB cable linking our PC to an STM32F4 based board, which acts as a bridge and simply sends everything received on USB to radio thanks to an embedded NRF module (nRF24L01+ chip). This mechanic goes both way (NRF -> USB -> PC). The board is running under C using FreeRTOS. The PC runs Windows 10.
On the PC side we use the official STM32 VCP driver 1.4 from ST. On the board firmware, we have this user-made library for VCP on STM32F4: https://stm32f4-discovery.net/2014/08/library-24-virtual-com-port-vcp-stm32f4xx/
There are no queues on the bridge board except the ones from the radio module itself and potentially the STM32 VCP driver itself. I checked, there is a circular buffer in this driver used for in and out messages. Using JSCOPE I can visualize in real time how this circular buffer behaves and I've never seen an overflow happening.
My problem comes from the fact that a delay suddenly appears.
The system works perfectly for tens of minutes (between 10 to 20 minutes) and then a delay is clearly perceptible, which makes the controller oscillate. This happens when I do a second flight.
The following have been tried:
- Restart the C# application
- Run the C# application in debug mode and stand alone mode
- Change USB cable (shorter)
- Change USB port
- Change of computer
- Reinstall the ST VCP drivers
- Lower drastically the communication frequency (the control loop)
When the problem appears, the above solutions didn't work, the delay remains completely and none of the above proved to make it more reliable.
On the C# application, I reset all communication Lists before each flight. The SerialPort port object (from System.IO) has its buffers reset as well (DiscardOutBuffer, DiscardInBuffer, BaseStream.Flush methods)
I found a "hack" to make it work, but it is not what we want as a final solution. The "hack" is to simply physically disconnect / reconnect the USB connecting the board acting as a bridge. After this manipulation, the delay disappears.
So my questions are:
What could possibly bring this delay, knowing it doesn't look to be application dependant, nor frequency related (bandwidth).
What could explain why this disappear when unplugging/plugging the bridge board ?
I know this question is about a big project and could be hard to understand from outside. Feel free to ask me for more details if needed.
Cheers,
Marc
I am currently working on a project where I need to control 16 pumps 1 stepper motor and 2 Distance sensors - 21 digital pins and 2 analog pins. I need to make a UI and have this use UI send information to the Arduino which will control my system. I would only need to receive 1 or 0 from each button press from the UI in order to determine which pump to needs to be turned on. I'm using an Arduino mega 2560 and coding the UI in Visual Studio C#.
I have done various research on serial communication for the Arduino, including using the serialevent() function and the firmata library. However I am having trouble understanding how all this ties together and if what I am wanting to do is even possible! Here are my questions:
Is this possible?
Is this possible by using Serialevent1()........... serialevent21()? or using Serial.availble() and Serial.read()
Instead of reading one button click on the UI at a time. Can the inputs on the UI be collected and sent to the arduino as a group. Then have the UI restart and clear out the values.
Any information and/or advice will help! I just need to be pointed in the correct direction!
Thanks
DG
Have you considered the following article?
It uses a Arduino mega 2560 and the article provides both the c# code and the Arduino code.
It communicates over the serial port and sends data in both directions.
Yes it is
The article above uses the Serial.print and readSerialInputCommand which is similar to Serial.read. You can use Serial.Read instead if you wish as it performs the same task and returns a different datatype.
You can compile the values into a group. If you want to be super optimized you can use bit-wise operators and compile the first 21 pin values into a byte array and send it.
However since its only 21 digital pins I recommend just using a string with the each character in the string linked to a pin. Eg: "10110" could set pin0, pin2, pin3 HIGH and set pin1, pin5 LOW.
I would recommend not restarting your UI as it will need to reconnect to serial port. Rather just clear all the values with your code.
I've been trying to get CellIDs for multiple cellular towers to triangulate the position of a windows mobile phone in a C# application.
I am able to get the lat/long of the currently connected cell tower using David Tiger's WMLocationInfo dll from http://forum.xda-developers.com/showthread.php?t=934948, but this is not accurate enough because it uses only the current cell tower. I need an accuracy of ~100M or so without using GPS. So if I can get the CellIDs and signal strengths of at least three towers, I'll should be able to improve the accuracy to a reasonable extent.
I found a discussion at Get Multiple Cell IDs for location using Cellular Towers C# Windows Mobile where johansebasb was addressing the same requirement.
Can someone point me towards a sample project or code that I can use for this?
Thanks in advance.
There are two probs with that:
The RIL does not expose that function
You may send AT^moni command to GSM modem but this may disturb or corrupt the RIL. The RIL is sending and parsing all commands to control the modem. Think of the RIL being the wrapper around all modem communication.
You need a comm port to send (inject) AT commands to the modem. That may be implemented or not by the RIL driver.
If the modem does not support AT^moni you are lost. The Siemens MC75 supports cell monitoring via:
AT^SMONC Cell Monitoring
The AT^SMONC execute command delivers cell information containing 9 values from a maximum of 7 base stations. The first base station is the serving cell.
AFAIK Sierra Modems do support AT^moni too. Qualcomm? Don't know.
I have an Arduino mega communicating over Bluetooth (bluesmirf gold device) to a C# application that I wrote. The Arduino is constantly sending a serial signal of 32 characters, the first always being an "S" and the last an "E". Using putty I can confirm that this signal is being sent correctly 99% of the time.
Now I want to read this signal with my C# application, which I am doing with the following code:
public string receiveCommandHC()
{
string messageHC = "";
if (serialHC.IsOpen)
{
while (serialHC.ReadChar() != 'S')
{
}
messageHC = serialHC.ReadTo("E");
serialHC.DiscardInBuffer();
}
return messageHC;
}
serialHC is of the serial class.
Sometimes this works perfectly but other times I'm having problems, I cannot find out why it works sometimes but others not.
The problem that I seem to be having is that sometimes I get a rather large Lag in the data that I am reading from the arduino. I notice this because I am sending button states and they only change a few seconds after I actually press or release the button on the Arduino. I used the standard baud rate of the Bluetooth device, which is 115200, and was wondering if changing that to a much lower rate could yield better results? What if any advantage would that have? I do not need hight communication rates, even updating the state 4-5 times a second would be acceptable for my application.
Is it possible the lag is coming from my code? I think it may be from the while loop that is waiting for the incoming "S" but then I don't see why it should hang there since there are new signals always coming in at a high rate.
I'm using the DiscardInBuffer() because I do not care about outdated data and just want to skip over that. It is much more important that I am reading current up to date data and acting on that fresh data.
Thank you for your help!
Best regards,
Bender
Update:
Just found out a bit more information while debugging. The problem only seems to appear:
When connected over Bluetooth (over USB cable there is absolutely NO Lag)
When a second Bluetooth connection is established from the PC to another device (different COM port and different baud rate)
Does anybody have any experience running two different devices off the same Bluetooth dongle on the PC? I can manage to connect to both no problem but still having the lag issue mentioned before.
Thanks for any help
You are not really using a physical serial port here. The BlueTooth driver merely emulates one. This is common, the Windows API has a well defined set of api functions to talk to a serial port. Emulating one makes the interface to the driver simple, the vendor doesn't have to supply an interface DLL or document a complicated DeviceIoControl() protocol.
Which means for one thing that the actual communication settings don't matter. Baudrate is meaningless in this scenario, it is the BlueTooth radio signaling that sets the transfer rate. The driver will accept whatever you select but will otherwise ignore it. Handshake signals might be interpreted, it's up to the driver to implement them. Communication error reporting is very rarely implemented, BlueTooth has an error correcting protocol, unlike a real serial port.
No, the loss of data here is entirely self induced. Clearly the driver does implement DiscardInBuffer(). Which accomplishes nothing but throw away any data that the driver received. This goes wrong if your code runs a bit late or gets interrupted by a thread context switch.
Delete the DiscardInBuffer() call.
I don't necessarily need to see real time plots or anything but as I understand it if you attach a USB device it gets like 100 mA then after some negotiation it will bump the power up to 300 mA or 500 mA so on and so forth till the device stops requesting.
Does anyone know of anyway to see all the USB ports on a machine and what they are "allowed" to output?
edit update:
in windows
preferably using a .net language
It must be available somewhere because if (in XP) you go to device manager and select one of the USB Root Hubs theer is a power tab in the properties dialog that details the power that has been requested by the devices plugged into each of the ports.
I am not a windows programmer so I do not know how to find this out programatically.
Shot in the dark, but if this data is anywhere, it'll be in WMI, or you might be able to get the info from an ETW trace of usbhub/usbport.
I found some interesting files under /sys but couldn't get anywhere with it.
In Ubuntu Linux, become root and cd to /sys/bus/usb/devices/usb1
root#pjb-desktop:/sys/bus/usb/devices/usb1# ls
1-0:1.0 bDeviceSubClass configuration idVendor speed
authorized bmAttributes descriptors manufacturer subsystem
authorized_default bMaxPacketSize0 dev maxchild uevent
bcdDevice bMaxPower devnum power urbnum
bConfigurationValue bNumConfigurations driver product version
bDeviceClass bNumInterfaces ep_00 quirks
bDeviceProtocol busnum idProduct serial
root#pjb-desktop:/sys/bus/usb/devices/usb1# cat bMaxPower
0mA
This seems to show current.
OK lets be a little creative here...
cat /sys/bus/usb/devices/usb?/bMaxPower0mA
0mA
0mA
0mA
0mA
0mA
0mA
0mA
will list all of them.
I tried plugging in a USB stick and got it active so the LED was blinking. I could not sense any change in these indications. There is also a power directory but I found nothing in there I could decipher..
So sorry if this is a dead end but I think with a bit more looking you might find what you are after.
You could just attach a 5V )(or slightly higher voltage, i.e. 6 or 7) adapter w/ the highest current rating you have on hand (you'll likely be pressed to even find one over 750mA), but it's only going to draw depending on the demand the attached devices require. In order to determine 'how much' or the ideal adapter, put a meter in the circuit and put your devices in their highest power requirement mode and read your meter (set on DC Amps)