Can PicBasic support 56700 serial baud?


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    If your PIC have an internal USART, sure it can work. I suggest you to download the PicMultiCalc and look what happen with the error % with different crystal speed
    http://www.mister-e.org/pages/utilitiespag.html

    @ 4MHz it's not going to be really accurate...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jan 2007
    Posts
    78


    Did you find this post helpful? Yes | No

    Default re: Can PicBasic support 56700 serial baud?

    Thanks Steve,

    I will check that out.
    I spent some time this weekend monitoring the bit streams between my pc and the device with a scope to both confirm the bit width is ~ 17uS, which it should be for 56.7k, and also to get a look at the bit patterns of returned info.

    Then I did a simple....

    Main:
    bo = 1
    high 5
    bo = 1
    low 5
    goto main

    To see what bit width I would see from a 4Mhz clock.
    And this came out to around 50uS.
    Perhaps if I removed the 'bo = 1's It would speed up a little, but no where near the speed needed. In order to read 56.7
    Looking in PBC.INC, it looks to me like 9600 baud is right at the timing limit with a 4Mhz clock. And since 56.7 is such a large jump, I think now a 40Meg chip slowed down to around 24Mhz might be the easiest way to do it using the built in SERIN / SEROUT commands.

    Anyway, I also checked out maxim's MAX3110E SPI/rs232 chip, and requested a couple of samples. I built up a schematic for it, and when they come in, I should be right on it.
    If I get this working I'll post the schematic and code.

    However, the reallity of my project is that I am only sending 2 bytes to the device, and these always the same. And the device is sending 4 bites back.
    I think with a little work, I can replicate the command bit stream with a 20Meg crystal. Decoding the incoming bytes will be the hard part.
    After sweating over that approach, I'll be eager to play with the Max chip.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dw_picbasic View Post
    Thanks Steve,

    I will check that out.
    I spent some time this weekend monitoring the bit streams between my pc and the device with a scope to both confirm the bit width is ~ 17uS, which it should be for 56.7k, and also to get a look at the bit patterns of returned info.

    Then I did a simple....

    Main:
    bo = 1
    high 5
    bo = 1
    low 5
    goto main

    To see what bit width I would see from a 4Mhz clock.
    And this came out to around 50uS.
    Perhaps if I removed the 'bo = 1's It would speed up a little, but no where near the speed needed. In order to read 56.7
    Looking in PBC.INC, it looks to me like 9600 baud is right at the timing limit with a 4Mhz clock. And since 56.7 is such a large jump, I think now a 40Meg chip slowed down to around 24Mhz might be the easiest way to do it using the built in SERIN / SEROUT commands.

    Anyway, I also checked out maxim's MAX3110E SPI/rs232 chip, and requested a couple of samples. I built up a schematic for it, and when they come in, I should be right on it.
    If I get this working I'll post the schematic and code.

    However, the reallity of my project is that I am only sending 2 bytes to the device, and these always the same. And the device is sending 4 bites back.
    I think with a little work, I can replicate the command bit stream with a 20Meg crystal. Decoding the incoming bytes will be the hard part.
    After sweating over that approach, I'll be eager to play with the Max chip.
    The 18F1220 already has a built-in UART that can easily be read using peeks and pokes. You don't need to 'bit-bang' serial with this PIC. At 57,600 baud, with continuous data streaming, each complete byte will arrive at about once every 173us. Just configure the onchip baud rate generator to set that up for you. With 173us per byte, that's plenty of time to check the RX port for a byte, get the byte, put it away somewhere, and do a bunch of other stuff, even at 4mhz, although you do have to use the high speed BRG in the 16 bit mode and even then you'll be about 2% high. Go to an 8mhz oscillator and you're less than 1% off the target rate.
    I guess what I'm saying is that either I don't get what you're doing (and I think I get it), or you're making this WAY harder on yourself than you have to.

  4. #4
    Join Date
    Jan 2007
    Posts
    78


    Did you find this post helpful? Yes | No

    Default re: Can PicBasic support 56700 serial baud?

    Hi Skimask,
    Thanks, however PBC doesn't have an include support file for that Pic.

    I think the PIC12F629, and PIC12F675 are supported, and they both have internal osc as well

    However, I did make progress today with a 12f675.
    Yup.... doing the bit-banging routine.
    By pokeing to GPIO register, and offsetting the internal clock to get the bit-width right.

    Today I was able to take over the device with the PIC.
    My next step is to get the A/D running and get some control buttons into the act.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dw_picbasic View Post
    Hi Skimask,

    I think the PIC12F629, and PIC12F675 are supported, and they both have internal osc as well

    However, I did make progress today with a 12f675.
    Yup.... doing the bit-banging routine.
    Just a heads up, I don't know if I'd trust that internal osc too far, at least not at some of the higher baud rates, and especially not at 57,600...maybe 9600, that would be about it. Temp, volts, etc. makes the internal osc drift too far once you get going too fast...

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    even @ 2400 baud, some PIC may don't work. Unless you want to waste your time to fine tune the internal osc (don't remind if you can do it with those 629 or 675), you should think of using a external crystal or a ceramic resonator.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Jan 2007
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    Well so far so good ( at least sending to the device) with just the little 12F675. I put the bit/byte patterns into eeprom and read them into bitstream output for each requested command to the device.
    I built a control switch pad this weekend using A/D on one pin.
    My next step is to include an encoded POT output device to control a second piece of equipment at the same time. I have two pins left..... oh boy !!

    These chips is fun!!

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serial reading of binary at 75 baud
    By JasonMarsh in forum Serial
    Replies: 5
    Last Post: - 20th February 2008, 16:36
  3. PicBasic Pro CAN Support?
    By RMUTR in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th November 2006, 00:19
  4. 110 Baud Serial Communications - Possible?
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th January 2006, 04:49
  5. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 02:17

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts