Need help with simple code

I’ve been using the wixel under different modes and it’s been a huge help with my projects at work and at home. In conjunction with a parallax propeller, I’ve developed a wireless controller for the ultrasonic test stations that I design. Using the wixel eliminated the cable that would carry a serial link. The test stations have a Parker/Compumotor 8 axis controller with a auxiliary RS232 port that the Wixel communicates through. The Propeller gets data from the AtoD converter(joystick pots and battery state), quadrature encoder and multiple switches and sends it all through the wireless serial app on the Wixel. The wixel has a socket on a custom PCB. The faceplate is a custom design as well as the case that was made on our rapid prototyper.(Pictures attached)
Will all that work I’ve managed to avoid learning much C, and I’m sort of stuck with the next project. I’ve tried to reverse engineer some of the existing apps, and read as much as possible of the SDK to no avail. This should be very simple:

Using a propeller and connecting to usart1 I would like to send 4 - 16 bit numbers to Wixel two. I would like Wixel two to be able to take these numbers with the servo library to control some servos or possibly flashing LEDs using PWM. I’m not sure if I understand the “Blocking” term fully, but I would like to know if the Wixel will be able to sustain the servos/PWM and keep up with 5-10 serial updates a second. If I understand right I want to make sure my code is non blocking, right?
I really appreciate this help. I’m good with basic, spin and all the stuff with Parker/Compumotor but I can’t get this to go.

Thanks

Norm S




Hello, Norm.

Your plan should work, but please note that designing a serial protocol and then writing the code to interpret incoming serial bytes for that protocol is a challenging task.

You can look at the example_usb_com app in the Wixel SDK for an example of how you could implement a multi-byte serial protocol with a mix of ASCII and binary commands. (You would only need the binary commands.)

That code is kind of complicated, so a simpler thing you can try is to just start with a very basic protocol: Let’s say that the propeller will send a byte between 0 and 255, and when the Wixel receives it, it will use the value of the byte to set the position of the servo. For example, let’s say that the servo position in microseconds should be 1500 plus the value of the byte (target = 1500 + byte). You should be able to do this in about 10 lines of code, and it should be non-blocking. You will need to read the documentation of the Wixel’s UART library and the documentation of the servo library. Please try it and let me know how it goes.

It’s important to start with something simple. Once you write this simple program, you will have learned more about how the Wixel works and you will be able to expand it to receive more complicated commands from the Propeller with 16 bits of data.

–David

David,
I’m going to try to modify the example you listed to just start reading the usart1. The example uses a virtual usb com port on the computer and I want to read a propeller. From what I see I can change usbComTxSend to uart0TxSend and other like calls. I also need to call uart1Init() and uart1SetBaudRate(param_baud_rate) that are uart specific. Just keeping to reading serial out on the Propeller is there anything else I should change?

Thanks

Norm S.

Yes, I think those are the only changes you need to make. I tried to make the USB serial functions be very similar to the UART serial functions, so it should be very easy to change the example program like you described. You don’t need to make “param_baud_rate”, you can just call uart1SetBaudRate with a constant argument.

–David

I’ve got a problem when I try to compile code with <radio_queue.h> and <uart1.h>. I’ve stripped it down to just the basic code:

#include <wixel.h>
#include <usb.h>
#include <usb_com.h>
#include <radio_queue.h>
#include <uart1.h>

void updateLeds()
{
    usbShowStatusWithGreenLed();
    LED_YELLOW(1);
    LED_RED(0);
}

void main(void)
{
    systemInit();
    
    usbInit();
    radioQueueInit();
	
    uart1Init();

    while(1)
    {
        updateLeds();
        boardService();
        usbComService();
       
    }
}

But I get:

Compiling apps/Test/test.rel
Linking apps/Test/Test.hex

?ASlink-Warning-Undefined Global ‘_radioQueueInit’ referenced by module 'test’
make: *** [apps/Test/Test.hex] Error 1
You may now close this window.

When the code was larger any calls using radio_queue.h (like radioQueueTxSendPacket(); or the above radioQueueInit() generate
the Undefined Global error. I’ve looked at every example and I don’t think I ever found the uart1.h and the radio_queue.h references
together. Am I missing something simple?

Thanks

Norm S.

Does your app have an options.mk file, and what is in it?

–David

David,
No, I didn’t no about that. I made a new directory under \apps and moved an original .c file into it.(forgot the name at this point) I started editing out what I did’nt want and started to compile. I got my propeller talking to the uart1 at 9600 turning on and off LEDs no problem. When I added the radio library is when things took a turn. Do I need a option.mk file? I also re-installed the SDK in new directory with the same results.

Thanks again,

Norm S

Yes. Please see the comment about options.mk here or just look at some of the other apps to see how they do it:

pololu.github.com/wixel-sdk/

–David