Has anyone tried AI with PICBASIC - Page 3


+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 81 to 97 of 97
  1. #81
    Join Date
    May 2013
    Location
    australia
    Posts
    2,440

    Default Re: Has anyone tried AI with PICBASIC

    I don't see any issues with IC address - it is done according to datasheet.

    1. Write to Config register:
    – First byte: 0b10010000 (first 7-bit I2C address followed by a low R/W bit)
    – Second byte: 0b00000001 (points to Config register)
    – Third byte: 0b10000100 (MSB of the Config register to be written)
    – Fourth byte: 0b10000011 (LSB of the Config register to be written

    when has a 7 bit i2c slave address ever worked in pbp?
    Warning I'm not a teacher

  2. #82
    Join Date
    Feb 2013
    Posts
    1,096

    Default Re: Has anyone tried AI with PICBASIC

    Does manual say anywhere that it won't ?

  3. #83
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,925

    Default Re: Has anyone tried AI with PICBASIC

    When manual says byte sized variables, it is implied 8 bits I guess.

    Ioannis

  4. #84
    Join Date
    Feb 2013
    Posts
    1,096

    Default Re: Has anyone tried AI with PICBASIC

    So this IC can't be used with PBP ?

  5. #85
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,925

    Default Re: Has anyone tried AI with PICBASIC

    I cannot see how one can send only 7 bits when the integrated command is set to send 8 bits...

    I think you have to make your own routine, maybe in assembly.

    Ioannis

  6. #86
    Join Date
    May 2013
    Location
    australia
    Posts
    2,440

    Default Re: Has anyone tried AI with PICBASIC

    I think you have to make your own routine, maybe in assembly.
    or convert the 7 bit address to an 8 bit address as i have explained multiple times in other posts
    Warning I'm not a teacher

  7. #87
    Join Date
    May 2013
    Location
    australia
    Posts
    2,440

    Default Re: Has anyone tried AI with PICBASIC

    just spotted this gem on the arduino forum

    you need to know better than the AI in order to know that the solution offered by the AI is wrong
    Warning I'm not a teacher

  8. #88
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,925

    Default Re: Has anyone tried AI with PICBASIC

    It makes perfectly sense!

    One cannot blindly trust the machine. The replies depend very much on the prompt anyway. So, if you do not how to ask or what to ask, then you cannot expect magic to happen, right?

    Ioannis

  9. #89
    Join Date
    Feb 2013
    Posts
    1,096

    Default Re: Has anyone tried AI with PICBASIC

    I would say, that for relatively simple coding routines, PBP knowledge of AI had been improved, but just when you ask something more complex, you'll get this:

    can you create picbasic pro code which will draw a circle on a LCD screen, which uses ST7920 controller?

    (I'm omitting some DEFINE's and other non-relevant stuff)

    Code:
    ' Initialize LCDLCDINIT' Main program loopMain:    ' Clear display    LCDOUT $01    ' Set cursor to home    LCDOUT $02    ' Set display to graphics mode    LCDOUT $3F    ' Set start line to 0    LCDOUT $40    ' Set display start line    LCDOUT $C0    ' Draw circle    CIRCLE 64, 32, 20
    

  10. #90
    Join Date
    Feb 2013
    Posts
    1,096

    Default Re: Has anyone tried AI with PICBASIC

    It makes very human-like errors.

    For example, I asked it how to convert the time from GPS receiver, which simply outputs digits in ASCII format to raw decimal digits, and here's the code:

    Code:
    hours = (time_data[0] - "0") * 10 + (time_data[1] - "0")minutes = (time_data[2] - "0") * 10 + (time_data[3] - "0")
    It assumed that "0" is the raw value of ASCII digit "0" In ZX Spectrum Basic it would be VAL("0"), but in PBP there's not VAL...

    Interesting, is there any other syntax of basic, which treats "0" as it's decimal value in ASCII table?

  11. #91
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,925

    Default Re: Has anyone tried AI with PICBASIC

    Minus "0" means in fact -48.

    Maybe this is what is needed by the rest of the program. With just this line I am not sure if it is right or wrong.

    As always, answer depends on the prompt. If you give enough and precise info you will get better response.

    Ioannis

  12. #92
    Join Date
    Feb 2013
    Posts
    1,096

    Default Re: Has anyone tried AI with PICBASIC

    yes sure, I changed "0" to 48 and everything works fine.
    The question is, from where it took "0", is there any programming language that can make ASCII to decimal conversion that way?

  13. #93
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,925

    Default Re: Has anyone tried AI with PICBASIC

    In every language "0" is equal to 48 dec. or "1" equal to 49, etc.

    Ioannis

  14. #94
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,550

    Default Re: Has anyone tried AI with PICBASIC

    What do you mean you changed "0" to 48 and it worked? I'm sure it worked fine with "0".
    You must stop mixing up the interpreted ZX BASIC with PBP.

    In PBP lingo
    48
    $30
    %00110000
    "0"
    are all representing the exact same thing, just differently for human readability.
    If you were to connect to 8 LEDs to PortB of your PIC and then do PortB = x where x is any of the above they would all result in the exact same thing being displayed on the LEDs.

    So, in your specific example subtracting "0" will subtract the numeric value 48 from the numeric value of the ASCII code for the digit question. This will result a numeric value equal to that of 'the digit'.

  15. #95
    Join Date
    May 2013
    Location
    australia
    Posts
    2,440

    Default Re: Has anyone tried AI with PICBASIC

    The question is, from where it took "0", is there any programming language that can make ASCII to decimal conversion that way?
    nearly all can do that, except that in C,C++ etc it would be '0' not "0" [single quotes is a chr 'literal' double quote is a null terminated "string" c-str]
    Warning I'm not a teacher

  16. #96
    Join Date
    Feb 2013
    Posts
    1,096

    Default Re: Has anyone tried AI with PICBASIC

    I'm not mixing, but with PBP

    X-"0" gives syntax error while compiling.

  17. #97
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,925

    Default Re: Has anyone tried AI with PICBASIC

    I am pretty sure it does not. Compiles just fine because "0" is in fact 48. So if X-48 compiles it will also compile X-"0".

    If course to have correct results you should not mix 0 (zero) with O (capital letter O) because they have different ascii value. But all compile fine.

    Ioannis

Similar Threads

  1. conversion from picbasic to picbasic pro
    By winjohan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st November 2011, 18:00
  2. Proton PICBASIC vs MeLabs PICBASIC
    By Fredrick in forum General
    Replies: 22
    Last Post: - 11th January 2008, 21:51
  3. PICBasic Pro vs Proton PICBasic
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd November 2006, 16:11
  4. picbasic 2.46
    By jojokatada in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th April 2005, 03:34
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 21:19

Posting Permissions

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