[XC-1A] Wrong behaviour of output pin

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
Post Reply
extremeRider
Member++
Posts: 19
Joined: Tue Jun 16, 2015 10:50 pm

[XC-1A] Wrong behaviour of output pin

Post by extremeRider »

Hi,
I wrote a function for moving a servo motor for the XC-1A board. The function works but every time a change the position, the voltage level of the pin goes to the logical level HIGH for a certain amount of time causing an undesired rotation of the servo.

Here is a screenshot of the oscilloscope to explain better the situation:

Image


Here is the code of my function:

Code: Select all

void servo_position(out port pwm_output, int usec_on) {
    pwm_output <: 1;
    delay_microseconds(usec_on);
    pwm_output <: 0;
    delay_microseconds(20000 - usec_on);
}
The function servo_position is called from another function that receives a message through a channel and contains an infinte while loop:

Code: Select all

void rotate_servo(chanend cmdS, out port pwm_output,
        streaming chanend spf) {
    int pos = 0;

    pwm_output <: 0;

    while (1) {

        select
        {
            case cmdS :> pos:
                pwm_output <: 0;
                break;
            default:
                servo_position(pwm_output,pos);
                break;
        }

        spf <: pos;

    }
}
I noticed that, when I switch on the board, the pin goes HIGH for 500ns every 20ms:

Image

I don't understand why the pin goes HIGH for 500 ns. Any suggestion?


User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Is this the behavior with or without the servo connected ?

If with connection to servo, disconnect the load and then do you see the same results ?

Which port pins on the XC-1A are being used for this project ?

Also consider to comment out some of your code -> compile and test again to see if the issue stops to assist with debugging the root cause.
extremeRider
Member++
Posts: 19
Joined: Tue Jun 16, 2015 10:50 pm

Post by extremeRider »

This happens w/ and w/o the servo.
I'm using a 1-bit wide port: XS1_PORT_1D on stdcore [2].

I'll do some other tests.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

With a hope to keep it simple, I would lean towards testing your code using one of the following free port pins:

X0D22 = P1G0 on stdcore[0]
X0D25 = P1J0 on stdcore[0]
X0D35 = P1L0 on stdcore[0]


Be sure to comment out the lines of code which access the port pin to confirm the issue does halt - if it does not, consider to test the same logic on one of the above port pins.

If still having issues and you are able to post your code, somewhere in the lab we have a few of the same XC-1A (G4 based) kits so may be able to test over the next few days.
extremeRider
Member++
Posts: 19
Joined: Tue Jun 16, 2015 10:50 pm

Post by extremeRider »

OK,
I'll try with these pins and then post the code if necessary.

Thanks!
Post Reply