Hi. I'm programming a 18f25k22 in circuit with pickit 2 and GCB and used this code to read values in GCB terminal but it's not the same as a uno. Any advice welcome.
#define USART_BAUD_RATE 9600
#define USART_TX_BLOCKING
do
get_range
HSerPrint "Distance= "
HSerPrint range
HSerPrint " CM"
HSerPrintCRLF
wait 100 ms
loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would hazard a guess that Stan expects the PICKit 2 to act as a USB-Serial Adapter with the terminal using the same pins.
If I am making a bad assumption, please ignore me, but this may be useful info for others moving from Arduino to PIC.
That won't work with the PICKit.
The Arduino has a Serial Bootloader whilst the PICKit is a Hardware Programmer.
You will need a USB/serial adapter connected to your 18f25k22 PIC's serial port in order to use the Terminal.
There are Bootloaders available for several PIC's but you would still have to program it with the PICKit the first time to install the bootloader and you will still need the USB/serial adapter . But once the Bootloader is installed you will be able to program Via the USB/serial adapter as you do the Arduino.
Cheers
Chris
Last edit: Chris Roper 2017-04-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you use the PICkit2 GUI then it has a built in terminal that connects through the programming pins. It works similar to the ARDUINO terminal window. It can even capture .csv data for import into excel.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And, so will Pickit3 hopefully. I have started to update Pickit3 to support serial and the new family of chips. I will create a new Sourceforge site very soon.
😀
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks all. Chris was correct. I thought boot loaders were just for serial programming. I had seen the pickit2 terminal being used and references to mplabx on google. I was using a zif socket but icp is just like programming a unu board. I suppose if I'd just bought a 328p chip I'd have to program the arduino boot loader first to use a terminal.
I've seen usb to rs232 adaptors recommended so I'll get some anyway. At the moment I'm ok with pickit 2 but should I get a pickit 3 clone?
If I download a bootloader, do I just flash it, then just program the chip as normal or are there any other considerations?
It's all new to me. I used home made parallel printer programmers once but they're obsolete now.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ps "18f25k22 PIC's serial port" means not the programming clock/data but RA4/RA5. Sorry to mention but that's the pins picaxe uses and I have a rs232 lead, tx/rx/ground. They use 2 resistors to make it compatable with laptops with poor rs232.
Could I use that lead to use the terminal? All seems a lot of messing around.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You should not equate Picaxe stuff with PIC stuff. If you do you will likely be wrong. Picaxe terminolgy does not generally apply to PIC or Great Cow Basic. So it's a good idea to forget Picaxe stuff when dealing with PICs and Great cow Basic.
ps "18f25k22 PIC's serial port" means not the programming clock/data but RA4/RA5.
This is incorrect.
Picaxe does not use a serial port for programming, It uses bit-banged software serial on RA4/RA5. The fact that Picaxe uses A4/A/5 for programming does mean they use a serial port. A quick look at the 18F25K22 datasheet shows that RA4/RA5 are not assigned to a serial port. The 18F25K22 has 2 hardware serial ports (USARTS) Port1 uses RC6/RC7 and Port2 uses RB6/RB7.
To use hardware serial to send data to the terminal app is rather simple. If you have a real serial RS232 Port on your computer use RC6 (PIN 17) for TX to the terminal this can be directly connected to the PC's RS232- RX. You will need to Set the SCKP bit "ON" in GCB source code to invert the TX data.
However, DO NOT connect the RS232 TX from the PC directly to PIC USART RX (Pin 18) as the voltage is too high. But it can be connected in the same manner as the Picaxe Download Circuit ( 2 resistors). PIC RX does not need to be connected to send data to the terminal. I use a serial cable with on end cut off and flying leads soldered on for GND, RX, TX, RTS, & DTR. (RTS or DTR can be used for serial programming with a bootloader)
If the PC does not have a serial port, then use a USB/TTL adapter that creates a Virtual Com PORT. . It is not necessary SET the SCKP bit of the BAUDCON Register when using a USB/TTL adapter. If you get a USB/TTL adapter, MAKE SURE that it brings out either RTS or DTR to allow serial programming with "TinyBootloader+" included with Great Cow Basic.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Evan. I'll look in serial solutions in GCB demos.I used a lcd. Serial communication terminology is new to me. It distracted me for a day looking at serial and bootloaders. I've never used rs232,maybe a mouse once and usb is just plug and play to me (when the drivers work!)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Stan, just a clarification here. The AXE027 programming cable is a USB/RS232(TTL) device. In other words The PC sees it as an RS232 CommPort. Unlike generic USB/RS232 converters the mini plug end of the cable does not produce standard RS232 voltage levels. The RX pin swings between 0V and +5V. IE, it never goes negative. This makes it a USB/RS232/TTL converter but it lacks all the control pins that utilize RS232 protocol. I've used it with VB6 (MSComm) like any other USB/RS232 converter (I have 4 of them) but using Software Flow Control only. This is because Hardware Flow Control requires use of the standard RS232 control pins.
So while you can't program a PIC with it you can use it with a Terminal for serial programs that don't require the control pins.
BTW, I peeked at the Ebay listings for USB/RS232/TTL converters. They're quite afordable and provide all the control pins required to satisfy RS232 standards.
Chris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@CDRIVE. 100% agree. I have am AXE027 hooked up on my test bench. Works via TTL inverter I built. ... now 5 years later I realise what a waste of my time to build that.... just by a converter from USB. 😀
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yeah Evan, I would imagine that direct USB/RS232/TTL converters (for the most part) puts the Max232 out of business too. I have quite a few USB/RS232 converters but I'm going to buy one of those ebay TTL models. I'm a China's Ebay junky! ;-)
Cheers,
Chris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you are not programming Picaxe Chips, you can download and run FTPROG on the AX027 ( or any genuine and some fake FTDI adapters) and change the TX & RX idle state. The FTDI chips are the only ones that are user programmable to invert or not invert the serial data.
Unfortunately most of the FTDI USB/TTL devices sold on Ebay are counterfeit/fake and FTPROG doe not work on some of these. . .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are quite a few warnings regarding inadvertently bricking the chip when runing any of their utilities. Personally I'd like to see a jumper or dip switch on the board to invert the logic instead of flashing it. In leu of that, additional (inverted) TX & RX pins would be preferable to flashing the chip.
Probably a fake/counterfeit as it looks/appears identical to other boards on EBAY costing as little as $1.49.
Given that an FT232RL chip alone costs $2.50 each in quantities of 2000 it is not likely that a genuine FTDI chip is used on a product costing less than the wholesale price of the chip.
I have flashed my AXE027 (Genuine FTDI Chip) at least 50 times and not bricked yet. Same with a genuine FTDI adapter from 4DSystems. Flashing with FTPROG is no more risky than updating the BIOS on a PC or any other device.
Many folks, (becasue of cheap prices) knowingly abandon their normally good ethics by supporting these counterfeiters... Yet I imagine these same folks would scream "foul" if someone stole their design, used substandard parts and sold it as the real deal for 1/4 the price.
That adapter should work fine. It also brings out DTR and RTS so it should also work with TinyBootloader App. I have had good experience with CP2102 based devices.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. I'm programming a 18f25k22 in circuit with pickit 2 and GCB and used this code to read values in GCB terminal but it's not the same as a uno. Any advice welcome.
.... and, what is happening? Can't guess what is not working. ....
Can't determine much without complete code and a precise description of the problem.
I would hazard a guess that Stan expects the PICKit 2 to act as a USB-Serial Adapter with the terminal using the same pins.
If I am making a bad assumption, please ignore me, but this may be useful info for others moving from Arduino to PIC.
That won't work with the PICKit.
The Arduino has a Serial Bootloader whilst the PICKit is a Hardware Programmer.
You will need a USB/serial adapter connected to your 18f25k22 PIC's serial port in order to use the Terminal.
There are Bootloaders available for several PIC's but you would still have to program it with the PICKit the first time to install the bootloader and you will still need the USB/serial adapter . But once the Bootloader is installed you will be able to program Via the USB/serial adapter as you do the Arduino.
Cheers
Chris
Last edit: Chris Roper 2017-04-02
If you use the PICkit2 GUI then it has a built in terminal that connects through the programming pins. It works similar to the ARDUINO terminal window. It can even capture .csv data for import into excel.
And, so will Pickit3 hopefully. I have started to update Pickit3 to support serial and the new family of chips. I will create a new Sourceforge site very soon.
😀
My guess.. I don't have one. Insufficient information.
But, we can but play.
He still has the serial cable hooked up to the Uno? Only joking.
The batteries in my crystal ball have died, I am clueless,
Thanks all. Chris was correct. I thought boot loaders were just for serial programming. I had seen the pickit2 terminal being used and references to mplabx on google. I was using a zif socket but icp is just like programming a unu board. I suppose if I'd just bought a 328p chip I'd have to program the arduino boot loader first to use a terminal.
I've seen usb to rs232 adaptors recommended so I'll get some anyway. At the moment I'm ok with pickit 2 but should I get a pickit 3 clone?
If I download a bootloader, do I just flash it, then just program the chip as normal or are there any other considerations?
It's all new to me. I used home made parallel printer programmers once but they're obsolete now.
ps "18f25k22 PIC's serial port" means not the programming clock/data but RA4/RA5. Sorry to mention but that's the pins picaxe uses and I have a rs232 lead, tx/rx/ground. They use 2 resistors to make it compatable with laptops with poor rs232.
Could I use that lead to use the terminal? All seems a lot of messing around.
I'll use a lcd for now.
Stan,
You should not equate Picaxe stuff with PIC stuff. If you do you will likely be wrong. Picaxe terminolgy does not generally apply to PIC or Great Cow Basic. So it's a good idea to forget Picaxe stuff when dealing with PICs and Great cow Basic.
This is incorrect.
Picaxe does not use a serial port for programming, It uses bit-banged software serial on RA4/RA5. The fact that Picaxe uses A4/A/5 for programming does mean they use a serial port. A quick look at the 18F25K22 datasheet shows that RA4/RA5 are not assigned to a serial port. The 18F25K22 has 2 hardware serial ports (USARTS) Port1 uses RC6/RC7 and Port2 uses RB6/RB7.
To use hardware serial to send data to the terminal app is rather simple. If you have a real serial RS232 Port on your computer use RC6 (PIN 17) for TX to the terminal this can be directly connected to the PC's RS232- RX. You will need to Set the SCKP bit "ON" in GCB source code to invert the TX data.
However, DO NOT connect the RS232 TX from the PC directly to PIC USART RX (Pin 18) as the voltage is too high. But it can be connected in the same manner as the Picaxe Download Circuit ( 2 resistors). PIC RX does not need to be connected to send data to the terminal. I use a serial cable with on end cut off and flying leads soldered on for GND, RX, TX, RTS, & DTR. (RTS or DTR can be used for serial programming with a bootloader)
If the PC does not have a serial port, then use a USB/TTL adapter that creates a Virtual Com PORT. . It is not necessary SET the SCKP bit of the BAUDCON Register when using a USB/TTL adapter. If you get a USB/TTL adapter, MAKE SURE that it brings out either RTS or DTR to allow serial programming with "TinyBootloader+" included with Great Cow Basic.
Thanks Evan. I'll look in serial solutions in GCB demos.I used a lcd. Serial communication terminology is new to me. It distracted me for a day looking at serial and bootloaders. I've never used rs232,maybe a mouse once and usb is just plug and play to me (when the drivers work!)
Stan, just a clarification here. The AXE027 programming cable is a USB/RS232(TTL) device. In other words The PC sees it as an RS232 CommPort. Unlike generic USB/RS232 converters the mini plug end of the cable does not produce standard RS232 voltage levels. The RX pin swings between 0V and +5V. IE, it never goes negative. This makes it a USB/RS232/TTL converter but it lacks all the control pins that utilize RS232 protocol. I've used it with VB6 (MSComm) like any other USB/RS232 converter (I have 4 of them) but using Software Flow Control only. This is because Hardware Flow Control requires use of the standard RS232 control pins.
So while you can't program a PIC with it you can use it with a Terminal for serial programs that don't require the control pins.
BTW, I peeked at the Ebay listings for USB/RS232/TTL converters. They're quite afordable and provide all the control pins required to satisfy RS232 standards.
Chris
@CDRIVE. 100% agree. I have am AXE027 hooked up on my test bench. Works via TTL inverter I built. ... now 5 years later I realise what a waste of my time to build that.... just by a converter from USB. 😀
Yeah Evan, I would imagine that direct USB/RS232/TTL converters (for the most part) puts the Max232 out of business too. I have quite a few USB/RS232 converters but I'm going to buy one of those ebay TTL models. I'm a China's Ebay junky! ;-)
Cheers,
Chris
If you are not programming Picaxe Chips, you can download and run FTPROG on the AX027 ( or any genuine and some fake FTDI adapters) and change the TX & RX idle state. The FTDI chips are the only ones that are user programmable to invert or not invert the serial data.
Unfortunately most of the FTDI USB/TTL devices sold on Ebay are counterfeit/fake and FTPROG doe not work on some of these. . .
William, thanks for the FTDI chip info. I was unaware of that.
Chris
Well after looking through the Ebay listings I Googled "FTPROG" and found ...
http://www.ftdichip.com/Support/Utilities.htm
There are quite a few warnings regarding inadvertently bricking the chip when runing any of their utilities. Personally I'd like to see a jumper or dip switch on the board to invert the logic instead of flashing it. In leu of that, additional (inverted) TX & RX pins would be preferable to flashing the chip.
For those interested in these converters I liked this one the best because it provides all control pins used in Modem communications, including 'Ring".
http://www.ebay.com/itm/FTDI-FT232RL-USB-to-TTL-Serial-Converter-Adapter-Module-w-USB-Cable-US-Seller-/201819631164?hash=item2efd632e3c:g:SrIAAOSwLnBX-GJy
Chris
Probably a fake/counterfeit as it looks/appears identical to other boards on EBAY costing as little as $1.49.
Given that an FT232RL chip alone costs $2.50 each in quantities of 2000 it is not likely that a genuine FTDI chip is used on a product costing less than the wholesale price of the chip.
I have flashed my AXE027 (Genuine FTDI Chip) at least 50 times and not bricked yet. Same with a genuine FTDI adapter from 4DSystems. Flashing with FTPROG is no more risky than updating the BIOS on a PC or any other device.
Many folks, (becasue of cheap prices) knowingly abandon their normally good ethics by supporting these counterfeiters... Yet I imagine these same folks would scream "foul" if someone stole their design, used substandard parts and sold it as the real deal for 1/4 the price.
http://www.starlino.com/ftdi-chip-real-of-fake-how-to-spot-a-fake-rt232r-rt232rl-and-others.html
https://thecounterfeitreport.com/product/562/FTDI--Chip-FT232RL-Chips.html
Last edit: William Roth 2017-04-05
Here is that same board listed on Amazon. Note that it states "Not genuine FTDI chip" in the description. Yet the chip is stamped "FTDI"
HI people. I ordered 1 of these but 3 quid to arrive in a week. http://www.ebay.co.uk/itm/like/152037156660?chn=ps&adgroupid=39613511478&rlsatarget=aud-292456216308%3Apla-279121852961&abcId=923836&adtype=pla&merchantid=110387893&poi=&googleloc=1007416&device=c&campaignid=737386489&crdt=0 I got a real rs232 port so why not just write vars to it? From a pin that does that and serial solutions in demos. Boot loader programming was not my intention.Is this converter going to catch fire? I never used debug,just write vars. It's all new to me. A glcd is fine with the GCB GLCD lib. Very nice and easy i2c if terminal is out. That's what I used for pic. Uno terminal. See what the postie brings.
That adapter should work fine. It also brings out DTR and RTS so it should also work with TinyBootloader App. I have had good experience with CP2102 based devices.
ps Evan recomended this to me. http://www.ebay.co.uk/itm/USB-to-TTL-Serial-Cable-FTDI-Genuine-chipset-3-3V-Black-/302247903498?_trksid=p2385738.m2548.l4275
Genuine FTDI based adapters are the best available. You cannot go wrong with one of these.