Shop OBEX P1 Docs P2 Docs Learn Events
Quickstart Board Clockmodes- Ground Issues?? — Parallax Forums

Quickstart Board Clockmodes- Ground Issues??

waymond91waymond91 Posts: 15
edited 2013-02-21 23:12 in Propeller 1
Hey All!
So I have been working on an autopilot for an RC airplane. I first tested my control model on an arduino board, once that was more or less working, I decided to scale up to a beaglebone. I did not make much progress with the beaglebone because I cannot get it working in real time. So I have arrived at the propeller!!
I am very happy with how this is works, and I have gotten over the anxiety of not using interrupts. There are still a lot of systems I need to bring up using this chip, but I am starting with reading the rc receiver. This basically sends pulses between 1-2 millis in order to write the servo position.
I spent the better part of the day pouring over the manual, and the counters release: http://www.parallaxsemiconductor.com/an001
A
fter going over the counter modes, and comparing my code with some other peoples objects, I wrote something that works!:
CON


  _clkmode = xtal1 + pll16x    'Run at the full 80MHz
  _xinfreq = 5_000_000


  elevator_in = 0
  
OBJ
  pst : "Parallax Serial Terminal"
VAR
  LONG stack[20]
  LONG cycles


PUB main


pst.start (115_200)


CTRA [30..26] := %11010               'Counter only adds FRQA to PHSA iff APIN is also HIGH
CTRA [5..0] := |<long [elevator_in]   'Attach elevator_in to APIN
FRQA := 1                                    'PHSA increments by values of 1


  repeat
    WAITPEQ ( |<long[elevator_in], |<long[elevator_in], 0)   'wait for elevator_in to go high, could be waitpeq(%1,%1,0) 
    WAITPNE ( |<long[elevator_in], |<long[elevator_in], 0)   'wait for elevator_in to go low
      cycles:= PHSA/(clkfreq/FRQA)                                 'now cycles should hold the number of clock cycles that past while elevator_in was HIGH
      pst.dec(duration)
      pst.newline
      PHSA := 0


However, I am having very strange issues. I am using the propeller quickstart board. If I hold the board in the air, it will not communicate back to my computer over the serial port (i have tried different cables).
If I leave it on the table, it will report values, and they will jump around, or sometimes stop. If I put my hand on the table, leave my seat, hover my hand over the board, etc this also seems to trigger serial communication (red LED onboard flashes).
In addition, even though I using any of the LED I/Os, if I run my finger along where the IOs solder in, or touch it in other places, the LEDs will light up.

I really cannot imagine what the issue is on this, any ideas? I am getting close to asking for a replacement...
Any help would be great!!!

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2013-02-21 22:30
    First let's get rid of the syntax issues. long[] is not any kind of cast but effectively an array access to hub memory. Which means waitpxx will just use |< elevator_in and the counter setup takes a pin number instead of a mask, i.e. ctra[5..0] := elevator_pin. Right now the counter is listening on pin 1 but the waitpxx happens on pin 0.
  • MagIO2MagIO2 Posts: 2,243
    edited 2013-02-21 22:59
    First of all, welcome to the forum and to propeller world!

    Reading your post and your code makes me believe that you are not very experienced in programming so far, but that you are very keen on implementing your autopilot. This is a very dangerous mixture! Dangerous because this mixture makes you want everything and now! But due to the lack of knowledge it often ends up in frustration and failure. You should really take the time to start from the beginning! Read the Propeller Education Kit Lab and do the exercises to really understand the propeller!

    Otherwise please let us know where and when you will do your test-flights, so that we can avoid this area at that time ;o)

    About the LEDs:
    If you have a look at the schematics of the quickstart, you can see that the LED's are driven by an extra driver IC. Leaving the pins of the propeller that control the LEDs as an input means that there is no defined logic level on the drivers input either. So, it could be enough to move your hand to charge/discharge these lines which will show up as blinking LEDs.

    On the other hand if your code does not read those input-pins there is no harm.
  • waymond91waymond91 Posts: 15
    edited 2013-02-21 23:04
    Excellent!!!!
    That took care of it. As I said, I am new to propeller, but even after just a couple days working with it, I have learned a little why the projects I have done in the past had to work the way they did. Thank you for the help!
    If anyone is interested, this seemed to read on receiver channel just fine:
    CON
    
    
      _clkmode = xtal1 + pll16x    'Run at the full 80MHz
      _xinfreq = 5_000_000  
    
    
      led1 = 23
      led2 = 22
      led3 = 21
      led4 = 20
      led5 = 19
      led6 = 18
      led7 = 17
      led8 = 16
    
    
      elevator_in = 0
      
    OBJ
      pst : "Parallax Serial Terminal"
    VAR
      LONG stack[20]
      LONG stack2[20]
      LONG duration,x
      
    PUB main
    
    
    pst.start (115_200)
    
    
    cognew(receiver_read, @stack)
    cognew(blinkleds, @stack2)
    
    
    PUB blinkleds
    
    
    DIRA := 000000_11111111_00000000_00000000
      repeat
        OUTA := 000000_11111111_00000000_00000000
        waitcnt(clkfreq + cnt)
        OUTA := 000000_00000000_00000000_00000000
        waitcnt(clkfreq + cnt)
    
    
    PUB receiver_read
    
    
    CTRA [30..26] := 010
    CTRA [5..0] := elevator_in
    FRQA := 1
    
    
      repeat
        WAITPEQ ( |<elevator_in, |<elevator_in, 0)
        WAITPNE ( |<elevator_in, |<elevator_in, 0)
        if PHSA > 0
          duration := PHSA/(clkfreq/1_000_000*FRQA)
          pst.dec(duration)
          pst.newline
          PHSA := 0
          
        
    
  • waymond91waymond91 Posts: 15
    edited 2013-02-21 23:09
    Just out of interest - I am not using to doing any binary or assembly - could we have declared APIN like this:

    CTRA[5..0] := %00001

    Is this a 5 bit or 32 bit register???
  • kuronekokuroneko Posts: 3,623
    edited 2013-02-21 23:12
    waymond91 wrote: »
    Just out of interest - I am not using to doing any binary or assembly - could we have declared APIN like this:

    CTRA[5..0] := %00001

    Is this a 5 bit or 32 bit register???
    Sure, why not (provided the pin is actually 1 and not 0 as in your initial posting). That said, readability would suggest sticking with decimal (0..31). Also, while ctrx is a 32 bit register, the bit access is limited to 6 bits [5..0] by the modifier. Note that this kind of bit operation is only possible with special registers (not normal DAT/VARiables).

    For example you could assign everything in one go: ctra := %0_11010_000 << 23 | elevator_pin.
Sign In or Register to comment.