Shop OBEX P1 Docs P2 Docs Learn Events
Can't get the adc0831 blocks to work in BlocklyProp — Parallax Forums

Can't get the adc0831 blocks to work in BlocklyProp

When I compile the attached (1st png file) BlocklyProp graphical code, I get the attached (2nd png file) message from the compiler. The PropC code generated indicates the BlocklyProp cannot find the "read_adc083x" function in the simpletons library. Both the code "A/D set Vref ..." and "A/D chip read ..." blocks are in the BlocklyProp block system.

How do I use the "A/D chip read" to read the "ADC0831" chip I have on my board.

Thanks, Clark

Comments

  • MattMatzMattMatz Posts: 87
    edited 2018-11-20 03:17
    Okay - Sorry about this, I'll check it out...this appears to be a bug. We should be able to correct it using a user-defined code block temporarily until we can get it patched.

    If you go to the system category, then choose the user defined code block, check the box, and set it to the following:

    Globals:
    int __Mvref = 330;
    int read_adc0831(int, int, int, int);

    Main Code: (don't add a semicolon!)
    read_adc0831(22, 21, 23, __Mvref)

    Main code is "a numeric value"

    Functions code:
    int read_adc0831(int __McsPin, int __MclkPin, int __MdoPin, int __MVr) {
    low(__MclkPin);
    low(__McsPin);
    pulse_out(__MclkPin, 250);
    int __Mvolts = shift_in(__MdoPin, __MclkPin, MSBPOST, 8 );
    high(__McsPin);
    return ((__Mvolts * __MVr) / 256);
    }

    The name of the function is spelled differently by the block, which is generating the error :(
    480 x 267 - 69K
  • MattMatzMattMatz Posts: 87
    edited 2018-11-20 03:18
    If you need me to, I can send you a blocks (SVG file) with those blocks in it you can just upload.
  • Wonder how this one slipped through?

    We're putting systems in place to prevent this from happening again. Thank you CJR for detailing the problem and Matt for fixing it.

    Ken Gracey
  • MattMatzMattMatz Posts: 87
    edited 2018-11-20 06:32
    Honestly, it's been there a long time, and the ADC0831 was a really last-minute add when we put it in 18 months or so ago.

    In the last months I was there, I started a propc library for A/D and D/A chips, including this one, the MCP series, and the digital potentiometer that's been included in so many of our kits for a long time. These blocks are some of the last ones that generate functions right in the code, and the goal has long been to move those functions into a library anyway.

    Probably time to do that.
  • Thanks Matt and Ken for the prompt responses.

    If you have block that will solve the problem until you get them put in a library, I would like to use them. I have code in C that works and I could have just made my own but I am trying to do the whole code in BlocklyProp.

    At Ken's suggestion, I am trying to learn the BlocklyProp system. I have developed a driver for a machine system we are developing for a proof of concept associated with a patent application we have filed. The code for the prototype uses a propellor flip module, a WX WiFi module, a OLED module and a adc0831 chip. The adc0831 chip is the interface to a sensor that is happiest at a 5v supply and reference. The current code was developed in propC because there is support for all the system physical components. I am converting it to BlocklyProp to see if I run into problems.

    In my prototype, the adc0831 is happy to operate and reference to 5v supply to the flip and communicate with the FLiP module's 3.3 digital inputs. I changed your code a little to make it work with my prototype controller board. The voltage reference "Vref (cv)" is now an argument of the "A/D chip read" function. The process helped me understand what is going on with the BlocklyProp system better. It all now works with my PCboard.

    Let me know when the BlocklyProp system update is published.

    I am attaching (3) files: 1) adc0831 BlocklyProp Code.png, 2)adc0831 BlocklyProp Expanded.png and 3) adc0831 PropC code.png that is the result. I don't know how to send an .svg file but I have one I can send if you tell me how.

    Thanks again, Clark
    983 x 505 - 149K
    982 x 815 - 139K
  • Looks like you got it working! I'm sorry I couldn't check back in right away. Unless it's really critical for us to get this one fixed ASAP, we may wait and do a larger update at the end of Dec. or early Jan. (when schools are on winter break). We really need to update Blockly's core (Google base code), and do some other maintenance stuff.

    Just let us know if getting the original block working is critical, or if using the custom block will tide you over for a few weeks.

    As for the .svg - that's under the menu in the top-right corner...the upload/download blocks file. It's will generate an SVG when you download it, and when you choose upload, you have the option to append or replace, so you could create a new project with just your single custom block, download the blocks file, and then send that SVG to anyone else for them to upload in, append, and then they would have your custom block.
Sign In or Register to comment.