Controlling an SCPI instrument in Simulink
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all,
I’m working on interfacing a dSPACE-based controller with a power supply that speaks SCPI, and I’m trying to figure out how to use their Ethernet blockset to do it, which is much like Mathworks' TCP/IP Send and TCP/IP Receive blocks. Because of how compiled Simulink models interact with their Ethernet hardware and drivers, I cannot use the Instrument Control Toolbox.
An example query would be “volt:prot?\r\n” to query the overvoltage threshold, and “volt:prot 50\r\n” to set it. The query would receive a reply something like “50\r\n”, and the command would receive no reply at all.
I can compose outbound messages easily enough with array concatenation, but I’m at a loss as to how to parse variably-sized incoming replies, or to accumulate incoming bytes until a reply has completely come across the wire. For example, a command of “<> STA?\r\n” requests a status, and gets a reply like “, 1, 2, 3, 4\r\n”. If I requested a buffer of 100 bytes, I’d have to send the command several times, and I’d get a number of replies glued together; if I requested a buffer of 1 byte, I wouldn’t know what to do with it until I got the “\r\n” pattern. I could write a stream-oriented parser for incoming messages, but that wouldn’t know, for a reply of ‘1000’, if the first ‘1’ should be multiplied against 1, 10, 100, or 1000, so that’s not a great solution.
Pure-Simulink solutions are ideal, since I need to generate code from this model, but I may be able to modify function blocks to do what's needed - the restrictions of the environment and toolchain make it dicey.
Thanks in advance!
2 Commenti
Marcelo Saboia
il 19 Apr 2019
Modificato: Marcelo Saboia
il 19 Apr 2019
Hello Chris,
I am trying to do almost the same thing you are doing (interfacing a dSPACE-based controller with a power supply that speaks SCPI) but in my case I need to use a Serial Communication (RS-232) and I would like to know how you send the SCPI Commands via SIMULINK.
I don't know how to convert a String Type variable (like your command “volt:prot?\r\n”) to ASCII to use as INPUT in the dSPACE Serial Communication blockset. My matlab is earlier than 2018a so a don't have the feature String to ASCII, and I am not pretty sure if this feature would be usefull.
Thanks in Advance,
Marcelo Saboia
Risposta accettata
Vinod
il 30 Lug 2017
Perhaps you can use the Simulink While Iterator to run a subsystem that reads in the data until a '/n' is received? In your subsystem you read one byte at a time and store it into a buffer that will then be used later in the processing chain.
0 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Direct Interface Communication in Simulink in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!