I am trying to make a program in SciLab that would make a real time plot from data received from serial port.
My idea is to execute new plot function after every single portion of data received. But I think it is too much work for the computer and SciLab will not work properly and miss data.
Do you know some option to plot real time data from serial COM port? SciLab or another free program?
It is perfectly possible to implement such a hardware setup run from a Scilab session that plots live data.
We do it #ENSIM, for practicals in optics: we move a translation actuator step by step (Scilab driver # https://fileexchange.scilab.org/toolboxes/255000, plugged to port#1), and for each step we read a transmitted signal with an optical powermeter (driver # https://fileexchange.scilab.org/toolboxes/223000, plugged to port#2). The refresh frequency of the powermeter is 1-2 Hz. So no problem to get a live plot of received data.
As well, we have written a Scilab driver for the very popular M38XR multimeter (# https://fileexchange.scilab.org/toolboxes/232000). A syntax is implemented to continuously display the live data coming from the multimeter (same low refresh rate ~1Hz).
Etc.
2 new Scilab drivers to come soon for new instruments (a furnace, and another popular multimeter). All our drivers presently on FileExchange will be updated for Scilab 6 and gathered in a single ATOMS module (then easier to document and maintain).
Related
I am generating a certain signal (digital pulse) in one of my verilog module running on programmable logic in Xilinx Zynq chip. Signal is pretty fast, with clock of about 200MHz.
I also have a simple linux and framebuffer Qt interface running for later controlling my application.
How can I sample my signal in order to make oscilloscope like interface inside my Qt app? I want to be able to provide visual of the pulse I am generating.
What do I need to use to be able to sample enough data at such clock frequency? And how do I pass it with kernel module or mmap to Qt?
You would do best to do what most oscilloscopes do: sample the data to RAM, and only then transfer it to the processor for display/analaysis, at a more "relaxed" pace.
On the FPGA side you will need a state machine that detects some sort of start or trigger condition, probably after a bit in a mode register is set from the software side to arm it.
The state machine will then fill samples into a buffer made of one or more block rams. If you want to placing the trigger somewhere in the middle of the samples captured, you should it as a circular buffer, and have it record continuously, stopping configurable number of samples after the trigger, so that some desired number from before the trigger condition remain un-overwritten by newer ones following it.
Since FPGA block rams are typically dual port, you can simply hook the other port up to your CPU bus for readout. You will probably want a register to read the state of the sampling state machine, and if you go with the circular buffer approach, the address where it stopped, so that you can unwrap the data to a linear record of time.
Trying to do streaming realtime sampling might be possible, but would be a lot harder and it is not clear that you could do anything meaningful with the data so produced in real time. Still, if you want to try you would probably need to put a FIFO buffer in between the sampling and the processor bus, as you will probably only be able to consume data in chunks, while having to service other operations in between, so something is needed to absorb the constant-rate inflow of samples. Another approach could be to try to build a DMA engine which would write samples directly to external system ram, but that will likely be even harder.
You could also see if there are any high speed interfaces available in the CPU which you could leverage - they might be things originally intended for video, for example.
It also appears that you are measuring only a digital signal, ie, probalby one bit. If you want to handle a higher input sample rate than the FPGA fabric can support, that could mean you could potentially use something like a deserializer block at the edge of the FPGA to turn the 1-bit input stream into a slower stream of wider samples to store.
In terms of output, once you have a vector of samples in a buffer it's pretty simple to turn that into a scope/logic analyzer type plot, with as much zooming, cursor annotation, automatic measurement or whatever you like.
Also don't forget that if the intent is only to use this during development, FPGAs and their tools often have the ability to build a logic analyzer right into the design, with the data claimed over the programming interface for plotting on a PC.
I've been writing a LabVIEW program to drive 3 axis Newport SMC-100 stepper motor controller for horizontal, vertical and rotational movement. I've implemented a for loop that repeatedly perform .3 degree turn followed by 5 separate horizontal movement until it turns a full circle. The program always fails at tellcontrollerstatus.vi, and gives me VISA 1073807339 timeout error. When I restart the program, it'll tell me there is no RS-232 connection available. The weird thing is, it happens at various loop iteration.
I'm sure the COM port setting is correct. If it's a simple program that tells the rotational stage to make a full turn in 1000 steps, it doesn't have any problem. It's only when I try to control two axes in each loop that I have problem.
I tried implementing delay using flat sequence but it doesn't really help. Eventually, I gave up changing the program and just tried another USB-RS-232 adapter cable. Then the problem is gone.
Although the problem was solved, it's not based on good diagnostic procedure and seems to be sheer luck. I'd like to know if there is a proper way to diagnose this kind of problem?
I always use addrcom to diagnose port.
http://www.ontrak.net/adrcom.htm
Also, you can short circuit pin 2 with 3 on DB9 and see weather do you receive the same data you have sent over COM. If you do so it means that your USB-RS-232 adapter cable working properly.
i am currently studying 3rd year CSE and have little to no background in electronics but i have suddenly taken an interest in robotics
i just started using arduino and its exciting. i got a bit of understanding of to code it (i know c and java). unfortunately i am lost when it comes to interfacing it with anything else other than arduino software. my teacher gave me a project to do as a begineer.
MY QUESTION: i was told to send a number (or sequence of numbers) to the arduino board. the board should blink the pin 13 LED (i know how to do this part) when it receives a number. then it should divide the number by two and send the result back to computer. here the computer must use "processing tool" to graph the number.
1. any help/hints are appreciated.
2. any idea on what this "processing tool" is actually called? all i was told was it was a software to graph numbers.
3. how to take output from arduino into another program as input?
thanks in advance
The processing tool is literally called Processing. It is a Java-based programmatic screen-drawing system that is very easy to use. Take a look at it here.
Processing is much like Arduino in that it has the setup(), loop() architecture and is similar in syntax.
To get data from the Arduino to Processing, you will need to send serial data to the PC.
I have a simple idea but I guess it's hard to implement it on simulink. I created a TCP/IP server between a BeagleBone and a simulink block using C code. I have a switch connected to the beagle bone as an input and my idea is to have a display on the simulink block showing if the switch is close or open. I couldn't do it because my client(simulink block) is a c code and it will do the job only once as C code ends the function execution after return to get the value of the switch. Do you guys know any simulink transfer mode or fancy C tip to transfer data between the Simulink client block and the display ?
In a simulator I've been working on we used a Sink block with remote IP address and IP port to export the data calculated at real time to an external listener (this could be on the same machine or connected via network) which in our case was a computer doing the graphics rendering, which was then picked up by a C++ code written using Ogre 3D and by another simulink model using a source block.
We also had an interactive chartplotter display (GPS position indication, if you will). We could access the values generated from simulink by calling the following command any time it was needed:
variable = get_param('Simulator/Chartplotter/YDot','RuntimeObject');
You could also call "set_param" to modify a constant value located inside the simulink model.
I don't have experience in beagle but I imagine you could have your C code execute a matlab scrip which would modify a logical constant present in your simulink model to indicate whether the switch is open or not.
Alternatively you could explore the first option but we only used it to get data out of simulink into the C program, not the other way around as you'd wish to do. I haven't got direct access to the receiving C code unfortunately but if you are really stuck I could ask my colleagues to send me the important bits.
Hope this helps.
I'm currently developing a small application for monitoring the power / current our solar collector is generating.
The array is connected to 3 inverters. Every inverter has a RS232 interface, transmitting one Line of information(its current status) every 10 seconds.
Since I want to do the monitoring using a device only having one serial port, I need to come up with a way to be able to read the data from all of the inverters in parallel.
I don't need to send anything to one of the inverters!
Is it possible to just connect 3 RS232 wires in parallel to one serial port? Collisions will be pretty unlikely since every inverter is transmitting only 64Byte / 10seconds ending with a newline, so I could check for variable line lengths to detect collisions.
I'm sort of chuckling at doomsday and wacky answers that so often pop up on stackoverflow...
But anyway, in years gone buy I have used paralleled RS-232 transmit lines using diodes and it can work fine for situations where collisions are unlikely. In one particular application I used this technique there were two input terminals where a user could key in simple commands to control the system (a specialized security system) and it was very unlikely that two people would be trying to control it at the same time from the two different terminals. Amazingly enough there are no problems with voltage levels with most RS-232A receivers I tested at the time and they tolerated the signal characteristics (no negative voltage) that result from the simple use of the diodes in series with the TXD signals. However, if I had to do this again I would likely add a simple pull-down resister and capacitor to ground with a diode between RXD and the cap in a sort of charge pump configuration or a pull-down to negative going handshake signal to ensure the "OR'd" input signal goes truly negative since the RS-232 spec defines +3 to -3v as invalid.
In any case, I would recommend not using this technique except in very specific, limited, and non-mission critical cases and would not use it in the case where you have multiple devices sending information at a programmed interval as in the case of the OP or where there is a software handshake.
In can be a simple solution to the problem of not enough serial input ports but only in a very limited set of environments.
No, you should NOT connect 3 serial output port in parallel. If you do that you are probably going to broke the RS232 output circuitry of your inverters.
You have 3 RS232 outputs, so you need 3 RS232 input, then you can manage these 3 input the way you like: maybe you can buffer the data from each input, and reoutput the data on a single RS232 output, to be connected to your monitoring device.... but you should add some code in the data flow to differentiate the data coming from the 3 inverters.
Maybe you can use some kind of IC that do the job for you, I'm not sure, but maybe that some IC that multiplex multiple RS232 input on a single RS232 output already exist.
Try this search: rs232 port input multiplexer on Google
Or, if the monitoring device is a Window computer, you can use 3 serial-to-usb converter: that will create 3 virtual COM port on your computer and you can read data from them with any software.
Update
About the hypothesis of securing the output circuitry using diods to block reentering current, I don't think it's going to work...
Many year have passed by since last time I've used an RS232 link at low level (so maybe I'm wrong) but I think that there is some kind of handshake going on between RS232 input and output port (speed to use, parity, stop bit...).
Each RS232 port have inputs and outputs signal, both for data and for transmission control, so your multiple RS232 outputs does have some input signals, and your single RS232 input does have some outputs.
This mean that your input monitoring RS323 port is going to try to make a handshake with 3 RS323 ports at the same time... and the 3 RS232 ports are probably going to respond at the same time... so I think it's not going to work.
Other than that if you place diodes on your output, you are going to loose 0.7v, I don't remember the tolerance on signal level of RS232, but maybe that 0.7v can be relevant.