Has anyone tried AI with PICBASIC


+ Reply to Thread
Results 1 to 40 of 89

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,079

    Default Re: Has anyone tried AI with PICBASIC

    Yes, correct.
    I have seen that with my own eyes - student asked to write a frequency meter code for arduino, she only specified that 4 digit, 7 segment display module was connected to the specified pins, and also specified a pin used as input - generated code worked directly and correctly, no modifications were needed. Both frequency measurement code, display multiplexing code - all were generated by AI.

  2. #2
    Join Date
    Feb 2013
    Posts
    1,079

    Default Re: Has anyone tried AI with PICBASIC

    Well, I tried that code and even after fixing syntax, it does not work.

    By the way, I tried to do my own code for that chip, but that also does not work - returns 64 for MSB and LSB bytes. The hardware wiring is correct, because if I remove VDD to chip, these bytes are returned as 0.

    Here's my code for it, according to chip 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)
    2. Write to Address Pointer register:
    – First byte: 0b10010000 (first 7-bit I2C address followed by a low R/W bit)
    – Second byte: 0b00000000 (points to Conversion register)
    3. Read Conversion register:
    – First byte: 0b10010001 (first 7-bit I2C address followed by a high R/W bit)
    – Second byte: the ADS111x response with the MSB of the Conversion register
    – Third byte: the ADS111x response with the LSB of the Conversion register


    Code:
    DO
    i2cwrite i2dta, i2clk, $48,$01,[132,131] 'write config
    pause 10
    i2cwrite i2dta, i2clk, $48,$0 'convert
    pause 10
    i2cread i2dta, i2clk, $48,[data1,data2] 'read data
    serout2 portc.5,90, ["adc=",dec data1, dec data2,13,10]
    LOOP

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,833

    Default Re: Has anyone tried AI with PICBASIC

    What is the purpose of this line?

    i2cwrite i2dta, i2clk, $48,$0 'convert

    Ioannis

  4. #4
    Join Date
    Feb 2013
    Posts
    1,079

    Default Re: Has anyone tried AI with PICBASIC

    I understand this as "start conversion(measurement)"

    As said in 2. of quote from the datasheet.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,393

    Default Re: Has anyone tried AI with PICBASIC

    are we still talking about a ds3231 ?

    if so then if chat gpt leads you to this there something terribly wrong


    DO
    i2cwrite i2dta, i2clk, $48,$01,[132,131] 'write config
    pause 10
    i2cwrite i2dta, i2clk, $48,$0 'convert
    pause 10
    i2cread i2dta, i2clk, $48,[data1,data2] 'read data
    serout2 portc.5,90, ["adc=",dec data1, dec data2,13,10]
    LOOP
    this is incorrect on so many levels starting with device address, conversion time and virtually every thing from there on
    Warning I'm not a teacher

  6. #6
    Join Date
    Feb 2013
    Posts
    1,079

    Default Re: Has anyone tried AI with PICBASIC

    No, this is ADS1115, as mentioned in comments in above post.

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

    Default Re: Has anyone tried AI with PICBASIC

    No, this is ADS1115
    ok that changes things a little.
    its now incorrect on so many levels starting with device address and virtually everything from there on
    i2cwrite i2dta, i2clk, $48,$0 'convert is not a legitimate i2c command either
    Warning I'm not a teacher

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