Shop OBEX P1 Docs P2 Docs Learn Events
FemtoBasic versions for Prop BOE & Activity Board — Parallax Forums

FemtoBasic versions for Prop BOE & Activity Board

Mike GreenMike Green Posts: 23,101
edited 2013-09-22 11:49 in Propeller 1
In honor of receiving a Propeller Board of Education, I've made some very minor changes to the QSBasic I posted recently to make it work with the Propeller Board of Education. I added I2C statements to allow reading and writing data to I2C devices like the BOE's ADC. I plan to add simple support for the BOE's DAC as well. Note that the micro-SD card driver only handles FAT16, so keep card sizes to 2GB or less and format them as FAT16, preferably with 32K clusters.

Updated archive. I2C statement changed to use 100KHz I2C bus speed. There were occasional errors with non-EEPROM devices at the higher 400KHz speed.
Updated 2012-03-25. SERVO statement now works properly. PING may or may not work properly ... needs more testing. Works with xBee (two compiled versions provided.
Updated 2012-03-26 Small changes to PING code and documentation.
Updated 2012-03-27 Rewrote BOEBOT.BAS example to run under PropBOEBasic. This is a modified "Roaming with PING" example.

See Post #11 for Activity Board version

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-03-24 18:26
    Here's a simple program to read the ADC. The display of millivolts assumes that the reference voltage is 3.3V.
    100 c = 0 : REM Channel number (0-3)
    110 t = I2C [28,$46,$10 SHL c,2]
    120 t = (t SHL 8) | (t SHR 8) : REM swap bytes
    130 t = (t & $FFF) SHR 2
    140 PRINT "Raw value (0-1023) = ";t
    150 PRINT "Millivolts = ";t * 3300 / 1024
    160 PAUSE 1000
    170 GOTO 100
    
  • Mike GreenMike Green Posts: 23,101
    edited 2012-03-25 15:59
    Here's a minimally tested version of PropBOEBasic that includes support for up to 6 servos and/or PINGs. See the included documentation for a description. I'll be doing some testing over the next few days and probably add IR distance sensing as well.

    Update: See first post for current version. SERVO works with any of the servo headers (I/O pins 14 - 19).

    For example, if you've plugged the left servo into the I/O pin 16 header and the right servo into the I/O pin 17 header, the following will set both servos to the midpoint of their range for calibration.
    100 servo[16] = 1500 : rem Set left servo to midpoint
    110 servo[17] = 1500 : rem Set right servo to midpoint
    120 goto 120 : rem Loop until stopped
    
  • Mike GreenMike Green Posts: 23,101
    edited 2012-03-25 22:20
    It looks like the PING statement doesn't work because the PING itself is broken. It'll be a while before I can get a replacement. If anyone with a PING and a Propeller Board of Education wants to help out, make up a cable to connect the PING and one of the servo headers on the PropBOE. Include the 3.3K series resistor mentioned in Post #1. Then try the following changing the 14 to whatever servo header you're using:
    100 print "Distance ";ping[14];" mm"
    110 pause 1000
    120 goto 100
    
    If you have a QuickStart board, you could also try this, but you'll have to supply +5V and ground to the PING as well since there's no servo header. You'd need to use one of I/O pins 14 - 19.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2012-03-26 06:25
    Hi Mike;

    Here is sample Femto code to drive a PCA9554 Buss Expander.
    I added the I2C command to my cobbled up version of DongleBasic.
    Works nicely!
    NEW
    1   PRINT"Application Programm for the"
    2   PRINT" PCA9554/PCA9554A I2C Buss Expander"
    3   PRINT"  Up to 16 of these devices can be"
    4   PRINT"   connected to a singleI2C buss"
    10  D=$40: REM Device Select Code "DDDDDDDx" include space for the R/W bit
    11  A= $7: REM Device Address the Wired Hardware Address
    12  C=$80: REM Configuration      Register 0=Output 1=Input
    13  P=$00: REM Polarity Inversion Register 0=Normal 1=Inverted
    14  O=$00: REM Clear the Output Port Register
    20    I2C[28,D+A*2,$3,1]=C: REM Configuration Register
    30    I2C[28,D+A*2,$2,1]=P: REM Polarity Inversion
    40    I2C[28,D+A*2,$1,1]=O: REM Output Port   Register
    50  I=I2C[28,D+A*2,$0,1]  : REM Input  Port   Register
    60  PRINT" D=";:PRINT D;
    61  PRINT" A=";:PRINT A;
    62  PRINT" C=";:PRINT C;
    63  PRINT" P=";:PRINT P;
    64  PRINT" O=";:PRINT O;
    65  PRINT" I=";:PRINT I;
    69  PRINT ""
    70  K=KEYCODE[0]:IF K=32 THEN INPUT "Output Byte ? ";O: REM Press "Space Bar"
    90  GOTO 40
    LIST
    RUN
    

    Duane J
  • Mike GreenMike Green Posts: 23,101
    edited 2012-03-27 11:26
    Got a new PING today and the PropBOEBasic version posted in the top of this thread works fine with it. Example (plugged into servo header for I/O pin 14):
    100 print ping[14];" mm"
    110 pause 1000
    120 goto 100
    
  • bee_manbee_man Posts: 109
    edited 2012-04-08 23:45
    wrote:
    Very important: As described in the PING object from the ObEx, you need a 3.3K resistor in series with the signal lead from the PING. The PropBOE doesn't have this, so you'll need to put a 3.3K resistor in-line in the cable from the PING.

    Mike,

    Doesn't the PropBOE have a 3.9K resistor on the signal pin of the 6 P14-P19 3pin headers already? This is needed only if you don't want to connect the ping to one of the standard 3 pin headers. Correct
    Just got my board a few days ago and have not had a chance to play with it yet.

    Jim
  • Martin_HMartin_H Posts: 4,051
    edited 2012-06-20 06:27
    bee_man wrote: »
    Doesn't the PropBOE have a 3.9K resistor on the signal pin of the 6 P14-P19 3pin headers already? This is needed only if you don't want to connect the ping to one of the standard 3 pin headers.

    Here's the schematic http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/32900_PropBOE_RevA_Schematic.pdf and on page 5 it looks like you are correct. That certainly makes connecting a Ping))) to the three pin header much easier. I think it also helps attenuate servo noise, which I've noticed seems to be more problematic with a 3.3v device and a single power supply.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-06-20 06:37
    Thanks bee_man and Martin_H for pointing out that the PropBOE already has a 3.9K resistor in series with the signal pins on the P14-P19 headers.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-08-13 10:54
    This version of BoeBotBasic also works with the Propeller Activity Board on a BoeBot chassis. If you want to use an xBee or WiFly module, you just need jumpers between DO/DI and P13/P12 just like with the Propeller BOE and you need to use the precompiled binary "PropBOEBasicXB".
  • Mike GreenMike Green Posts: 23,101
    edited 2013-09-22 11:49
    I've modified PropBOEBasic (see attachment) to support the Activity Board's built-in ADC using the function ADC[<channel>]. The SERVO statement has been changed to properly handle the different I/O pins used on the Activity Board for the servo headers (12-17 instead of 14-19) and the xBee Rx and Tx pins are expected to be connected to I/O pins 10-11 instead of 12-13.

    Edit: Changed ADC channel numbers from 1-4 to 0-3 to match labels on Activity Board. Added DAC statement to set DAC channels 0 (audio Right) or 1 (audio Left) to a value from 0-255 to provide voltages from 0 - 3.3V with 8-bit resolution and a PWM frequency of 22KHz. This uses PhiPi's PWM object from the ObEx.
Sign In or Register to comment.