FTDI USB to PicAxe 08M (IT WORKS)

Simmicht

Senior Member
I have a good news story to share and document for the future.
I bought the really cool USB to RS232 breakout from SparkFun and it uses the FT232RL USB to serial IC.
http://www.sparkfun.com/commerce/product_info.php?products_id=9115

From the breakout board, I wired the GND, 5V, TX, and RX to my PicAxe 08M and it would not work nor program. (Hair pulling starts)

I down loaded the FT_Prog.exe from http://www.ftdichip.com/ and did the following to invert the RS232 logic that the breakout is using by default.

I have installed the VCP drivers from http://www.ftdichip.com/Drivers/VCP.htm

1. Connect FTDI device to USB and close any applications that are using the COM port associated with the USB Virtual Port.
2. Run the FT_Prog.exe program and scan for devices.
3. Under Hardware Specific, I set the HighIO to true by checking the box.
4. Then I checked all the InvertRS232 signals options.
5. Lastly, I selected Device Program, selected Device 0, then clicked Program.
6. I disconnected and reconnected the USB breakout, connected it to the PicAxe 08M and YES it programmed and returned the data as required.

Good luck (hair pulling replaced by back slapping)
 

womai

Senior Member
One more detail about the FTDI chip (or better, its related driver) that can bite you. Per default the VCP USB driver's timeout is set to 64msec. USB block size is 64 bytes. The chip will wait until it has received a full block of data or until the timeout hits.

That means if you only send small data packets (say, 1 byte at a time), it will take 64msec before the timeout hits and the data actually gets sent. Which can make for very slow transmission, especially if you have a bidirectional connection where data bounces back and forth - every exchange will now take 64msec. Happened to me at my latest scope design, which worked fine with a "normal" RS-232 connection, and worked - but much slower - when I added the FTDI interface.

The solution is relatively simple - go to the Windows device manager, look up the corresponding (virtual) COM port, choose "Advanced Options" and set the timeout to 2msec (don't set it to less than that because this can create problems of its own).

Wolfgang
 

Janne

Senior Member
The axe027 usb cable also seems to include the same chip, but in a more convenient qfn package. Neat, and just a bit more expensive, so well worth it imho =)
 

manie

Senior Member
As far as I am concerned, if the Axe027 cable works, and mine does nicely so, leave well alone. If it ain't broke....., don't fix it I say. Like Janne says, a little bit extra cost but prompt despatch service from Tech-Supplies makes up for that. I do all my 433MHz RF Input/Output via the Axe027 cable...
 

womai

Senior Member
Agree, AXE027 is easy to use with a Picaxe (it has the TX/RX inversion already enabled). I have a couple myself. What it does not offer - and apaprt from about 50% lower cost which was the reason I chose the FTDI solution - is access to the USB 5V supply to power your circuit (in my case that removed the need for an external supply for my new scope design, reducing cost as well as size and clutter).

Wolfgang
 

Simmicht

Senior Member
Used in the project not the development

@maine I should have mentioned this was not to replace the standard RS232 and power used during development but to use in the "production" version.

As mentioned in the previous post, the breakout board added a COM port and supplies the 5V to power the sensors and PicAxe which I am using as a temperature monitoring device. A friend wanted to monitor inside and outside temp and record the data on a computer that is running 24/7. Plugging a device into the USB that sends the temps via a COM port is just what he wanted. Add a 08M and 2 DS18B20 chips on leads, plus a FTDI USB to RS232 and then magic happens.

Code:
'Written/Modified Aug 2009 
'Written for 08M
#picaxe 08M
#terminal 2400

'Use two DS18B20 as the temperature sensors for air and ground temps
'Uses LED to flash temp,  flash for TENS, medium for UNITS and short for DECIMAL

'STATUS String TX to Network for analysis by Monitoring Computer
'$#ID #Data *#CHECKSUM, CR,LF









SYMBOL      ControllerTXPin        = 0        'IO    0 = PIN 7 connected to Diode and then to RS232
symbol      TXbaud             = N2400    'N for direct connection to RS232 and T for via XBee
'symbol      xbeeTXbaud             = T2400
symbol      TXPeriod            = 60         'data every x Seconds

SYMBOL     TensDelay            = 700
SYMBOL     UnitsDelay            = 250
SYMBOL     DeciDelay            = 50


SYMBOL      AirTempPin             = 2    ' T2 Input  4 = PIN 3 connected to DS18B20
SYMBOL      GndTempPin             = 4    ' T1 INPUT  2 = PIN 5 connected to DS18B20
SYMBOL      LED               = 1    ' IO         1 = PIN 6 connected to BLUE LED

symbol      ControllerID        = 9


Symbol     Temperature            = W2
Symbol     AirTemp            = W6
Symbol     GndTemp            = W5
SYMBOL     TimeInSecs            = B7



'PEEK/POKE MEMORY MAP

'80 - Level (WORD)          
        Symbol AirTempAdr1    = 80
'81 - Level (WORD)         
        Symbol AirTempAdr2    = 81
        
'82 - Seconds ON (WORD)
        Symbol TimerAdr1         = 82    
'83 - Seconds ON (WORD)
        Symbol TimerAdr2         = 83    

'84 - Level (WORD)          
        Symbol GndTempAdr1    = 84
'85 - Level (WORD)         
        Symbol GndTempAdr2    = 85


TimeInSecs = 80        'Initialise Timer so status done at startup


Loop1:



pause 1000
TimeInSecs = TimeInSecs + 1        'Increment counter for time to wait
ResetTimer:


if TimeInSecs < TXPeriod then Loop1    'Not time yet to do stuff  


readTemp12 AirTempPin,AirTemp
readTemp12 GndTempPin,GndTemp


'AirTemp

B0 = ControllerID                    'Controller ID and also initialise the CheckSum
SerOut ControllerTXPin,TXbaud,("$", #B0,",")

'Transmit the  AirTemp
W4=AirTemp
Gosub SendTemp12            'W6 is used for the readtemp12 temp


'tranmit the GndTemp
W4=GndTemp
Gosub SendTemp12            'W6 is used for the readtemp12 temp



'Transmit the Checksum
SerOut ControllerTXPin,TXbaud,("*", #B0)
SerOut ControllerTXPin,TXbaud,(cr,lf)




FlashLEDTemp: 'Flash out the temp    12 bit temp in B0 B1 (W0)

IF AirTemp<4096 then SkipNeg
AirTemp=AirTemp ^$ffff+1            'take twos complement to make +ve
;========Show Neg flashes  10 really fast
    for B6=1 to 40
    toggle LED:    Pause 15
    next b6



SkipNeg:

B2 = AirTemp / 16
B3 = AirTemp // 16
B3 = B3 * 10 + 8 / 16 ; bring it back to 0 to 9

B1 = B2 /10        ; Tens value
B0 = B2 //10    ;Units value

IF B1=0 then DoUnits
FOR B4=1 to B1       ;Flash then Tens
    High LED        ;Turn if ON
    Pause TensDelay
      IF B4=5 then EXtraTensDelay
    Goto Next1
EXtraTensDelay:
    Pause UnitsDelay
Next1:
      LOW  LED        ;Turn if OFF
    Pause TensDelay
Next B4
    Pause TensDelay

DoUnits:
IF B0=0 then DoDecimal
FOR B4=1 to B0           ;Flash then Units
    High LED        ;Turn if ON
    Pause UnitsDelay
      IF B4=5 then EXtraUnitDelay
    Goto Next2
EXtraUnitDelay:
    Pause UnitsDelay
Next2:
      LOW  LED        ;Turn if OFF
    Pause UnitsDelay
Next B4
    Pause TensDelay

DoDecimal:


FOR B4=1 to B3           ;Flash then Decimal
    High LED        ;Turn if ON'
    Pause DeciDelay
    LOW  LED        ;Turn if OFF
    Pause DeciDelay
Next B4




TimeInSecs = 0                'Reset counter for time to wait
GOTO ResetTimer



'============================================================
SendTemp12:
B2=32    ' space Character
IF W4 < 4096 then SkipNeg1i
W4 = W4 ^$ffff+1            'take twos complement to make +ve
B2=45    ' - Character

'Send the sign or space
'sertxd (B2)
SerOut ControllerTXPin,TXbaud,(B2)
B0=B0+B2                        ;Checksum calcs

SkipNeg1i:



W3 = W4/16                        'Calc the Integer part of temp
B2 = W3

'sertxd (#B2,".")
SerOut ControllerTXPin,TXbaud,(#B2,".")
B0=B0+B2                        ;Checksum calcs
'sertxd ("B0=",#B0," B2=",#B2,cr,lf)


B6 = W4 // 16                    'calc the decimal part
LOOKUP B6,("0112334456678899"),B6        'convert decimal part to a character
B6 = B6-48                        'Convert to didgit instead of ASCII

'W1 = W6 *10 ' convert to  Decree C by 10


B0=B0+B6                        ;Checksum calcs
'sertxd ("B0=",#B0," B6=",#B6,cr,lf)
'sertxd (#B6,",")
SerOut ControllerTXPin,TXbaud,(#B6,",")
RETURN
 

hax

New Member
Mine seems to be dropping or altering ASCII characters.

The FTDI programs the Picaxe just fine, but when I send a string and expect a reply, about once in every 5 times, the picaxe does not respond.



I am using a 20X2 on 3.3V and I am using the serrxd and sertxd commands.

Setting setfreq M4 drops the 9600 baud to 4800 baud but the problem persists.
 

hax

New Member
Also if I get the picaxe to repeat what was sent, often (one in 6 or 7 times) the letter gets scrambled.

When I use Docklight, I can see the binary stream.... the problem is with the first bit of the stream, sometimes it is a 1 when it should be a 0


I tried calibfreq but it does not help.
 

womai

Senior Member
Weird problem. If it's any help, in my scope design I transmit about 10 KBytes of data per second bidirectionally (PC to PIC and vice versa), and that link has been running for many days without a single lost or corrupted byte.
 

hax

New Member
Womai What chip are you using?

And are you using the serin and serout programming lines or a dedicated input and output pin?
 

womai

Senior Member
I am using the FTDI FT232R. My new scope is not based on a Picaxe (couldn't do 1 MSamples/sec real-time sampling without external logic), but a dsPIC30F2020. I'm using the hardware UART to communicate between FT232 and dsPIC. I also ran the FT232 with a 18F4520 which is basically the same as a 40X2. Never ran into any data corruption problem and I am running the link at up to 250 kBaud. (theoretically it could go up to 1 MBaud but I don't need that speed).

To be on the safe side make sure that "strong driver" is enabled in the FT232R.

Wolfgang
 

hax

New Member
I think by "strong driver" you mean the high I/O current option..... yep tried that.... It's about time I grabbed the logic analyser and had a look.
 

womai

Senior Member
One more idea - depending on whether you are using inverted data, the initial state of the line my not be be correct (e.g. initially low when it should be high). That could cause corruption of the first character.
 
Top