Shop OBEX P1 Docs P2 Docs Learn Events
PLX DAQ with Propeller C — Parallax Forums

PLX DAQ with Propeller C

FMFFMF Posts: 2
edited 2013-11-04 21:57 in General Discussion
I am trying to use the PLX DAQ plug in for Excel with a Propeller Activity Board in C. I have not been able to locate any resources or examples in C. I have been able to transmit using this:
fdserial *PDAQ = fdserial_open(31, 30, 0, 9600);  // serial port  dprint(PDAQ, "RESETTIMER, \n");
  dprint(PDAQ, "CLEARDATA, \n");
  dprint(PDAQ, "LABEL, Time, Timer, Val 1 \n");  
  while (1) {
    pause(1000);
    dprint(PDAQ, "DATA, TIME, TIMER, 1 \n");}

However, I am not sure how to use the get cell value directive. I am trying to use the following but it seems like its getting hung up when it tries to receive. I have no idea if this is a possible way to do this, I don't fully understand these serial communications.
fdserial *PDAQ = fdserial_open(31, 30, 0, 9600);  // serial port    
dprint(PDAQ, "CELL, GET, I1, \n");
byte = fdserial_rxChar(PDAQ);

Thanks,any help is appreciated.

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-11-04 20:22
    Is this the method that you're trying to replicate in PropGCC?
    Pub CellGet(Cell)
    {{
      Gets the specified cell's integer value (no text or decimals) in Excel  
      to be accepted by the BASIC Stamp                                       
      PLX-DAQ String: CELLGET,D5                                             
      Note that CellSet works only with hex values for columns A to F         
     ┌────────────────────────────────────────────────┐                       
     │ X := PDAQ.CellGet($A3)                         │                       
     └────────────────────────────────────────────────┘                       
    }}
       Serial.rxflush
       Serial.str(string("CELL,GET,"))
       Serial.hex(Cell,2)
       CR
       return Serial.RxDecTime(500)
    

    From the documentation above it looks like it might not be possible to get columns past F? Is there any authoritative document on the PLX DAQ protocol?

    Anyway, assuming that you can get past F you should probably remove the last "," and get rid of the extra spaces in your string
    dprint(PDAQ, "CELL,GET,I1\n");
    

    From the Spin version above it looks like the return value is a DEC string, aka something like "92754", possibly with a terminating '\0' or '\n'. Your rxChar will just return the first character ('9' in this example) without getting the full number. You should use some sort of DEC routine.

    Also, I don't know where the dprint is from, so I can't provide any help there.

    If you're using stdio.h you might want to check that PLX DAQ doesn't care about \r\n instead of just \n: https://sites.google.com/site/propellergcc/documentation/faq#TOC-Q:-What-s-the-deal-with-the-extra-r-when-I-get-a-n-on-the-stdin-
  • SRLMSRLM Posts: 5,045
    edited 2013-11-04 21:10
    Ah, it looks like you can use getDec from simpletext.h to read in a decimal number: https://code.google.com/p/propsideworkspace/source/browse/Learn/Simple%20Libraries/Text%20Devices/libsimpletext/simpletext.h#150
  • jazzedjazzed Posts: 11,803
    edited 2013-11-04 21:41
    Hi, and welcome to the forums.

    Sometimes we need to use fdserial_rxTime() to check if a character is available within a certain number of milliseconds.

    All library documentation is in the Simple Library folders as html. We often point to the header which is on-line for convenience.

    libfdserial documentation where things like fdserial_rxTime can be found is here:
    https://propsideworkspace.googlecode.com/hg/Learn/Simple Libraries/Text Devices/libfdserial/Documentation fdserial Library.html

    Some links in my .signature point to some Propeller C resources also.
  • FMFFMF Posts: 2
    edited 2013-11-04 21:57
    I seem to have things working now, the spaces in the get cell directive string were not supposed to be there. I will look at the documentation to see what I can use to decipher the bytes on the way back. Thanks everyone.
Sign In or Register to comment.