Hi,
I am brand new to GCBASIC. I come from the PICAXE users world.
What I'm looking for is actual code samples that show
the PICAXE serout C.1,T4800_4,(132,5,112,46)
PICAXE command serout, PIN C.1, BAUD 4800, Data (132,5,112,46)
converted to a GCBASIC example.
Simple lines of code in GCBASIC to do the same job from header, declarations to program end.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is software serial, meaning that the Chips USART is not being utilized.
T4800_4 Sets the Baud at 4800 with serial pin "idle high" and the chip is
operating at 4MHz. The Serial output is on Picaxe C.1. 4 bytes of data are sent.
Personally I would not operate the PIC at 4 MHz and neither would I use software
based ( bit-banged) serial unless there was a very good reason. Like a very old chip
with no UART.
Maybe software serial is being used because of Pin constraints where the hardware serial pin is not available. Or a previous board design has you handcuffed into using C.2 for serial out?
In that case use a PIC chip that has Peripheral Pin Select (PPS) I will use a PIC 18F47Q43 as an example but it could be any PIC with a PPS module like an 18F27K42: A chip with PPS allows the use of many pins for hardware serial.
#Chip 18F47Q43, 64
#CONFIG MCLRE = ON
#OPTION Explicit
#Startup INITPPS, 85 'Call INITPPS sub here to set PPS
#DEFINE USART_BAUD_RATE 4800
#DEFINE USART_TX_BLOCKING ' Prevents USART TX Buffer Overuns
Set Portc.2 on
Wait 200 ms 'SYSTEM STABILIZE
'Main program begins here
MAIN:
Hsersend 132
Hsersend 5
Hsersend 112
Hsersend 46
DO
Loop
'------------ Subs and Functions Below -----------
Sub InitPPS 'USE PPSTOOL TO Easily set up PPS
'Module: UART pin directions
Dir PORTC.2 Out ' Make TX1 pin an output
'Module: UART1
RC2PPS = 0x0020 'TX1 > RC2
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the info. I guess I need to learn the PIC18F27Q43 chip PINs ... what PINs are for Serial I/O, what PINs are PWM, what PINs are ADC, what PINs are I2C etc.
The PICAXE manual had nice graphics that I used for reference when scribbling my programs.
Then I use another PIN to send serial data to a Pololu Maestro Servo Controller for multiple servo motor control;
20210803 HexBot+Maestro12 Test9 https://youtu.be/AyuBF5Pyk4U
Now I want to have my little palm size robots to sing a full song and play music for long videos.
I'm guessing the UART is my best choice and I guess PIN RA5 is for receiving, but I don't understand the datasheet so well, so I emailed MicroChip support to help me create a list of PIN functions to speed up my learning process.
Let me explain PPS a bit better. By setting a PPS register you can tell the serial out (TX1) which pin to use, Same with the serin pin (RX1). On the PIC 18F27Q43 you can use any pin on PORTB or PORTC. You have 16 choices.
Some peripheral inputs, like RX1. have a default pin assigned. However it can be reassigned to any pin on PORTB OR PORTC. On the other hand peripheral outputs, likeTX1 , MUST be assigned to a pin.
BTW your 18F27Q43 chip has 5 UARTS so you can use more than 1 if you need to. This makes sending and receiving asynchronous serial to multiple devices much easier.
PPS gives you the flexibility to select multiple Pins for peripheral inputs and outputs. Instead of being stuck with only one.
At the top of the IDE, on the toolbar there is an icon labeled "PPS" . Click on it and wait a bit for the files to load and the PPS TOOL to open. When it opens, select the correct chip. Then use the input and output sections to select the Peripheral inputs and outputs and assign them the pin you want to use. Use the ADD button to add the selections to the pane on the right. When done click on Copy. Then switch to the GCB code window and PASTE. That will set up the PPS. It is not difficult at all. There are many examples in the Help and in the DEMOS.
The PPS TOOL can also tell you which PIC Chips are PPS Enabled. If the chip is in list then it has PPS. Play around with the tool and learn how to use it. You can't hurt anything.
Bill
Last edit: William Roth 2021-08-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will send you my email address via this forum if I remember how.
I will say I am a cheapskate and use re-engineered toys from charity shops... cos it's a good cause.. and it's cheap and saving the planet.... well not if you still use lead based solder.
Seriously, I don't buy expensive kits. Getting stuff working cheap is a main incentive to build something.
Like I said. Audacity is excellent free audio editing win software... ie play around with your own voice so it sounds like r2d2. Save it as mp3 and burn to sd card and use a sd card mp3 player like I did. Supported in gcb as the demo was gcb. The device was bought from picaxe but a few £ on ebay.
Very simple to use.. usually 255 tracks. Nice to have a bit of sound and the easiest/cheapest way.
I thought about phrases my rover could say when it encountered an obstacle but they would be unsuitable to publish.
ps I got two £80 diy 3d printers and I've printed some nice fan enclosures for the nozzle.
Loads of stuff from Thingiverse.
Last edit: stan cartwright 2021-08-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You've been busy!
I clicked your name -- wperko in the gcb forum and it has a send message option so sent you my email address. I only use gcb for projects... not c, python or anything else. Hoping to get freebasic on raspberry pi working with the gpio plug in .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am brand new to GCBASIC. I come from the PICAXE users world.
What I'm looking for is actual code samples that show
the PICAXE serout C.1,T4800_4,(132,5,112,46)
PICAXE command serout, PIN C.1, BAUD 4800, Data (132,5,112,46)
converted to a GCBASIC example.
Simple lines of code in GCBASIC to do the same job from header, declarations to program end.
Picaxe Code: serout C.1,T4800_4,(132,5,112,46)
This is software serial, meaning that the Chips USART is not being utilized.
T4800_4 Sets the Baud at 4800 with serial pin "idle high" and the chip is
operating at 4MHz. The Serial output is on Picaxe C.1. 4 bytes of data are sent.
Personally I would not operate the PIC at 4 MHz and neither would I use software
based ( bit-banged) serial unless there was a very good reason. Like a very old chip
with no UART.
Nevertheless here is the GCB code
Maybe software serial is being used because of Pin constraints where the hardware serial pin is not available. Or a previous board design has you handcuffed into using C.2 for serial out?
In that case use a PIC chip that has Peripheral Pin Select (PPS) I will use a PIC 18F47Q43 as an example but it could be any PIC with a PPS module like an 18F27K42: A chip with PPS allows the use of many pins for hardware serial.
Thanks for the info. I guess I need to learn the PIC18F27Q43 chip PINs ... what PINs are for Serial I/O, what PINs are PWM, what PINs are ADC, what PINs are I2C etc.
The PICAXE manual had nice graphics that I used for reference when scribbling my programs.
I use one PIN for hserout to send data to a SpeakJet chip for talking and singing;
Tapper Sings "I Gotta Get Me Some" https://www.youtube.com/watch?v=ic9aR1kmu74
Then I use another PIN to send serial data to a Pololu Maestro Servo Controller for multiple servo motor control;
20210803 HexBot+Maestro12 Test9 https://youtu.be/AyuBF5Pyk4U
Now I want to have my little palm size robots to sing a full song and play music for long videos.
This one was three program sets;
This is America Song & Musical Milk Cartons https://www.youtube.com/watch?v=6X4s0H3kWIY&ab_channel=WaltPerko
I'm looking at this chart from the datasheet for the best PINs to use for serial data.
https://www.microchip.com/en-us/product/PIC18F27Q43
I'm guessing the UART is my best choice and I guess PIN RA5 is for receiving, but I don't understand the datasheet so well, so I emailed MicroChip support to help me create a list of PIN functions to speed up my learning process.
Last edit: wperko 2021-08-14
:-)
This did make me smile. Do let me know how you get on with emailing Microchip support.
I wouldn't discount playing around with the Mega(Atmel2560) Board. Lots of Timers and PWM that can go low at 50HZ.
Here is some background on the Atmet2560 Mega Board servo PWM setup https://sourceforge.net/p/gcbasic/discussion/projects&guides/thread/66153766/#ae47
Let me explain PPS a bit better. By setting a PPS register you can tell the serial out (TX1) which pin to use, Same with the serin pin (RX1). On the PIC 18F27Q43 you can use any pin on PORTB or PORTC. You have 16 choices.
Some peripheral inputs, like RX1. have a default pin assigned. However it can be reassigned to any pin on PORTB OR PORTC. On the other hand peripheral outputs, likeTX1 , MUST be assigned to a pin.
BTW your 18F27Q43 chip has 5 UARTS so you can use more than 1 if you need to. This makes sending and receiving asynchronous serial to multiple devices much easier.
PPS gives you the flexibility to select multiple Pins for peripheral inputs and outputs. Instead of being stuck with only one.
At the top of the IDE, on the toolbar there is an icon labeled "PPS" . Click on it and wait a bit for the files to load and the PPS TOOL to open. When it opens, select the correct chip. Then use the input and output sections to select the Peripheral inputs and outputs and assign them the pin you want to use. Use the ADD button to add the selections to the pane on the right. When done click on Copy. Then switch to the GCB code window and PASTE. That will set up the PPS. It is not difficult at all. There are many examples in the Help and in the DEMOS.
The PPS TOOL can also tell you which PIC Chips are PPS Enabled. If the chip is in list then it has PPS. Play around with the tool and learn how to use it. You can't hurt anything.
Bill
Last edit: William Roth 2021-08-15
@wperko , gave your vid a like. I like "robots" .
Voice and a face display . My intentions, to amaze my grandkids :)
I can do face graphics and gcb supported sd mp3 player with my voice through win audacity which can do amazing things with a sound sample,,, get the old version as the new one has spyware.
Can make a robot look more like a bought one but I like retro.
I posted my "robots" before but to show not messing with you here's the gcb laser range finder.
https://www.youtube.com/watch?v=s5-5DNa36jk&list=UUwOlmqc5IB4FhvS5XKu1sLw&index=25
I want a face and sound
https://www.youtube.com/watch?v=4LnerMCgeNU&list=UUwOlmqc5IB4FhvS5XKu1sLw&index=91
nice to meet a "robot" builder
I will send you my email address via this forum if I remember how.
I will say I am a cheapskate and use re-engineered toys from charity shops... cos it's a good cause.. and it's cheap and saving the planet.... well not if you still use lead based solder.
Seriously, I don't buy expensive kits. Getting stuff working cheap is a main incentive to build something.
Like I said. Audacity is excellent free audio editing win software... ie play around with your own voice so it sounds like r2d2. Save it as mp3 and burn to sd card and use a sd card mp3 player like I did. Supported in gcb as the demo was gcb. The device was bought from picaxe but a few £ on ebay.
Very simple to use.. usually 255 tracks. Nice to have a bit of sound and the easiest/cheapest way.
I thought about phrases my rover could say when it encountered an obstacle but they would be unsuitable to publish.
ps I got two £80 diy 3d printers and I've printed some nice fan enclosures for the nozzle.
Loads of stuff from Thingiverse.
Last edit: stan cartwright 2021-08-17
You've been busy!
I clicked your name -- wperko in the gcb forum and it has a send message option so sent you my email address. I only use gcb for projects... not c, python or anything else. Hoping to get freebasic on raspberry pi working with the gpio plug in .
link does not work also contact on the site. I can not send my email address
Connected now.
I want to hack these not use loads of servos.
Last edit: stan cartwright 2021-08-22