Shop OBEX P1 Docs P2 Docs Learn Events
Increase com speed?? — Parallax Forums

Increase com speed??

GJGJ Posts: 19
edited 2006-07-17 12:36 in General Discussion
I am making an interface for an X-Ray system using the Javelin as the I/O.
Ideally, it will scan the I/O, shift in 8 channels of analog data and three bytes of digital data and send this information to a PC via RS232.· The data packet should be about 21 bytes long.

My problem is that it seems to take about 60 ms to transmitt that data.· I was hoping to scan the inputs at 1kHz, but if it takes 60ms to transmitt the data, I can't scan at 1kHz and the PC can never respond in time.

Is there a faster alternative communication method, do I need some other device, or am I looking at my problem wrong?· I set up a simple test using the RS232 on the demo board.· I pulsed an LED, transmitted 20 bytes of data, then pulsed the LED again.· I used a scope to measure the time between the pulses at about 60 ms.

At the very worst, I need to scan the ports and send my data packet and be ready to scan the ports again 60 times per second.· This is the worst case that I can accept.

Thanks

Comments

  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-07-15 04:08
    Have you considered trying either an SX or Propeller chip?

    The SX series can be programmed in Basic, ASM, or C, and will give you up to 80MIPS. Yes, 80MIPS!

    The Propeller can be programmed in Spin or ASM, and I think the max is ~20MIPS. With Spin it is fully object oriented, and the chip has 8 independent, 32-bit processors in the core. Yes, 8 processors!

    You can post in the other forums for more info.
  • GJGJ Posts: 19
    edited 2006-07-15 04:34
    I have thought about the SX series. I guess the question is this, is my problem one of machine speed, or simply Uart baud rate being simply too slow.

    If the later is the problem, then maybe the solution is to utilize a 3 wire serial to USB or ethernet chip if either exist. The shiftout method can move data at a considerably higher data rate. The other thing I noticed was that the time for the data to transfere via my RS232 was the same regardless of the baud rate. I used 36400, 19200, 9600. I changed the code for the Javelin, changed the setting in Hyperterminal and went into device manager and changed the configuration for the port there. I am using a USB to RS232 adapter for the laptop running Hyperterminal, maybe that only operates at 9600? By the way, here is my little test ap

    import stamp.core.*;
    public class HyperTermCOM { //COM Port (9-pin serial)
    final static int SERIAL_TX_PIN = CPU.pin0; // 2
    final static int SERIAL_RTS_PIN = CPU.pin1; // 7
    final static int SERIAL_CTS_PIN = CPU.pin2; // 8
    final static int SERIAL_RX_PIN = CPU.pin3; // 3
    static Uart txUart = new Uart(Uart.dirTransmit, SERIAL_TX_PIN, Uart.dontInvert, Uart.speed38400, Uart.stop1);
    static Uart rxUart = new Uart(Uart.dirReceive, SERIAL_RX_PIN, Uart.dontInvert, Uart.speed38400, Uart.stop1);
    static StringBuffer buffer = new StringBuffer(128);
    public static void main() {

    do{
    CPU.writePin(CPU.pins[noparse][[/noparse]10],true); //turns led on and is used for scope probe
    CPU.delay(500);
    CPU.writePin(CPU.pins[noparse][[/noparse]10],false); //turns led off,
    txUart.sendString("12345678900987654321"); //transmit data
    CPU.writePin(CPU.pins[noparse][[/noparse]10],true); //turn led back on
    CPU.delay(500);
    CPU.writePin(CPU.pins[noparse][[/noparse]10],false); //turn led off
    } while (true);
    }
    }
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-07-15 07:57
    The maximum speed at which the uart buffer can be filled from
    the javelin program is about 10 kbit/s, though the buffer contents
    can be transmitted (in the background) up to 57600 baud.
    Throughput is therefore limited to 10000 baud, or 1000 bytes/s,
    or 1000/21 = 48 messages/s (each message 21 bytes).
    So you can not have·60 messages/s.
    The SX can·achieve this.

    Then again, 8 channels of analog data, lets say 12bit adc values, is only 96bits or 12 bytes.
    Adding 3 bytes of digital data, makes a message length of 15 bytes.
    That gives 1000/15 = 67 messages/s.

    So you may be able to use the javelin, but you need to provide more info on how
    you read your analog data and the size of that data, and how you read your
    digital data.

    regards peter
  • GJGJ Posts: 19
    edited 2006-07-17 11:59
    Thank you.· I've been working on reducing the data and here is where I am at:
    Byte 1········ Start Byte = FF
    Byte 2········ Length = total number of bytes being transmitted
    ********* Digital Data ***********
    Byte 3········ X-Ray system controller status
    Byte 4········ Upper 4 Bits·· Imaging System Magnification Mode (Binary Coded Decimal)
    Byte 4······· ·Lower 4 Bits·· Frame rate selection (Binary Coded Decimal)
    ********** Analog Data **********
    Byte 5&6···· Imaging System Brightness Feedback (typically varies 0 to 6V 12 bit resolution needed)
    Byte 6········Kilovoltage used in making the X-Ray· (40 to 150 KV, the analog voltage typically being 0 to 10V)
    Byte 7&8·····mA used in makeing the X-Ray (10 to 1000mA, analog value 0 to 10V, resolution needed for accuracy)
    Byte 9········ Imaging stand rotational position
    Byte 10······ Imaging stand skew positon
    Byte 11······ X-Ray source to X-Ray detector distance
    Byte 12······ Table height position
    Byte 13·······Checksum mod 256

    So, with the above, I can achieve 75 messages per second.

    ???
    Why can the SX work faster?·Since the Javelin communicated in the background, I would have thought· it would have be faster.
    Would I achieve a faster data rate using the FTDI serial to USB chips and using shiftout command instead of the Uart?
    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-07-17 12:13
    The SX excutes code natively, whereas the javelin executes bytecodes.
    So the javelin program is interpreted by the JVM that is programmed
    into the firmware.
    Using spi makes it slower, because spi is done in the foreground.
    Use uart to send data to pc, use spi to read in sensor data.
    That way, both tasks overlap each other.

    How do you interface your sensors to the javelin?

    regards peter
  • GJGJ Posts: 19
    edited 2006-07-17 12:36
    Thank you for the information.



    I am working on the sensor interface today.· The digital data will be opto isolated and will need to handle DC values 5,12,15,24 volts and AC values 110V and 220V.

    On the analog side, each input will need to go through an op amp with some sort of variable gain for scaling. I am planning on using a digital pot to set the gain of the op amps.·The challange is to provide proper isolation for the analog side.·
Sign In or Register to comment.