Writing to digital pins of E1 using MATLAB not working

Applications, development tools, FPGA, C, WEB
Post Reply
swartjean
Posts: 11
Joined: Mon Jan 04, 2016 12:27 pm

Writing to digital pins of E1 using MATLAB not working

Post by swartjean » Fri Jan 08, 2016 10:27 am

Hi everyone,

I'm having some trouble with using SCPI commands in MATLAB to write to the digital pins of E1.
For some reason the pin state never seems to change.

Is my order of operations correct or am I missing anything?

I set the pin to an output
fprintf(tcpipObj,'DIG:PIN:DIR OUTP,DIO1_N');

Then I set it high, query the pin state, pause, set it low and query the pin state again.

fprintf(tcpipObj,'DIG:PIN DIO1_N,1');
pinstate0 = query(tcpipObj,'DIG:PIN? DIO1_N');

pause(2)

fprintf(tcpipObj,'DIG:PIN DIO1_N,0');
pinstate0 = query(tcpipObj,'DIG:PIN? DIO1_N');

When I display the value of pinstate0 it is always either ERR!ERR!1 or ERR!1.

Has anyone had anything similar or can you inform me what I'm missing? I'm still very new to the Red Pitaya.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Writing to digital pins of E1 using MATLAB not working

Post by Nils Roos » Sat Jan 09, 2016 6:04 pm

Are you able to use other scpi-commands successfully ?

If not, did you start the scpi-server (see 2. in these instructions) ?

swartjean
Posts: 11
Joined: Mon Jan 04, 2016 12:27 pm

Re: Writing to digital pins of E1 using MATLAB not working

Post by swartjean » Mon Jan 11, 2016 8:24 am

Hi Nils,

All other SCPI commands are working absolutely perfectly as far as I can tell.

I just managed to seemingly solve the issue by altering my MATLAB script to first SSH into the Red Pitaya using plink and use the monitor tool to set the required pin as an output. The script then starts the SCPI-server and the digital pins seem to work properly.

I'll report back here if I have any more problems but do you have any idea what could be causing this?
I find it strange that setting the pin mode to output manually has this effect as I was under the impression that the pins defaulted to output mode?

Thanks very much

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Writing to digital pins of E1 using MATLAB not working

Post by Nils Roos » Sun Jan 17, 2016 2:56 pm

I've just been looking into the GPIO part of the scpi-server more closely, and one thing I noticed is that the direction values are "IN" and "OUT", so maybe the "OUTP" in your direction statement is the root of the problem.

Since the scpi documentation defines "INP" and "OUTP", I'd consider this a bug in the scpi-server. Also, the default seems to be input instead of output, which I'd see as a bug in the documentation, because default output is usually a bad idea for GPIOs.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 37 guests