Shop OBEX P1 Docs P2 Docs Learn Events
Using the Type K thermocouple and the MCP9600 AMP — Parallax Forums

Using the Type K thermocouple and the MCP9600 AMP

I want to build a high temperature readout for my wood burner, up here in the frozen waste land of the north...lol.

I have purchased the above items, but I am really have a hard time with the I2C format into the BS2. Wondering if someone out there has done this, and would like to share your I2C source code. I have tried to read about I2C, and how to write the code, but I still cannot figure it out.

Just to add, I am not a new comer to the Basic Stamp or the Propeller...have made many many devices over the last 20 years with the Stamp..

Thank you for your time....DenO

Comments

  • JonnyMacJonnyMac Posts: 8,929

    While not impossible, I2C is not easy on the BS2. Do a web search for "StampWorks" -- there is a chapter having to do with I2C and it has the core routines needed to communicate with I2C devices.

  • dennodenno Posts: 221
    edited 2024-03-10 14:09

    Thank you JonnyMac, many years ago, approx. 20, I used Sparkfuns HMC 6352 compass module, and built a directv satellite tracker for my boat. As the boat swung in the anchorage in calm waters, that device would hold 1 degree of accuracy in azmuth. Elevation, was fixed at the dish itself. The HMC6352 was I2C and I was using a BS2sx, at the time. I still have one HMC6352 on a breadboard and for some reason I cannot get it to work. Is it because the sx is faster??

    I will search for "Stampworks", but was wondering if I could show you the source code I am trying to use, you could show me the error of my ways...thank you

    PS..my web search did not show anything, or I simply could not find it...most likely the latter..

  • JonnyMacJonnyMac Posts: 8,929
    edited 2024-03-12 20:53

    I tend to think in terms of the standard BS2 (the OG BS2). If you have a BS2p (or pe or px) then things are better. It uses an SX chip and has I2C built into it.

    You can post your source code here where anyone can help you. Use three back-ticks in before and after the code so it gets formatted properly.

  • dennodenno Posts: 221
    edited 2024-04-04 20:55

    And here is an interesting one to figure out...first I will display the Constants

    'Constants
    on_ CON 1 'notice the hyphen
    off CON 0

    I have used the above for 20 years working with all Stamps to simply turn on an LED when necessary in the program.
    Next is just a sample, on how I ALWAYS turned on and off LED's.....
    'PIN ASSIGNMENTS
    up_temp_LED PIN 4
    dn_temp_LED PIN 5
    burner_temp_LED PIN 6
    room_temp_LED PIN 7

    up_temp_LED = on_
    dn_temp_LED = on_
    burner_temp_LED = on_
    room_temp_LED = on_
    PAUSE 1000
    up_temp_LED = off
    dn_temp_LED = off
    burner_temp_LED = off
    room_temp_LED = off
    PAUSE 1000
    Now, the above code using an BS2sx the (4) LED's will not turn on.....PERIOD!
    Using the code below, using the same BS2sx the (4) LED's will turn on and off.......

    HIGH up_temp_LED
    HIGH dn_temp_LED
    HIGH burner_temp_LED
    HIGH room_temp_LED
    PAUSE 1000
    up_temp_LED = off
    dn_temp_LED = off
    burner_temp_LED = off
    room_temp_LED = off

    Why does the HIGH work when the CONSTANT on_ 1 does not?
    For many years I have used (on_ and off) to turn on LED's. Please notice the (on_) does have a hyphen added so as not to be taken as the COMMAND (ON)

    PS....took me 4 hours to figure this out...and a rum and coke...LOL and I did get the MPC9600 amplifier from Sparkfun to work with the BS2sx using I2C. However, there is an error of about 35% across the range to 450 degrees F.

  • JonnyMacJonnyMac Posts: 8,929
    edited 2024-04-04 21:15

    Why does the HIGH work when the CONSTANT on_ 1 does not?

    Because you haven't set your pin(s) to output state (1 in the DIRS register); HIGH and LOW write 1 to the pin's DIRS bit.

    Here's how to do it; you can use HIGH or LOW to initialize your pin, and then use = IS_ON or = IS_OFF after because the DIRS bit is already setup.

    ' =========================================================================
    '
    '   File......
    '   Purpose...
    '   Author.... Your Name
    '              Copyright (c) 2024 Your Name
    '              MIT License Applies
    '   E-mail....
    '   Started...
    '   Updated...
    '
    '   {$STAMP BS2}
    '   {$PBASIC 2.5}
    '
    ' =========================================================================
    
    
    ' -----[ Program Description ]---------------------------------------------
    
    
    ' -----[ Revision History ]------------------------------------------------
    
    
    ' -----[ I/O Definitions ]-------------------------------------------------
    
    LED             PIN     10
    
    
    ' -----[ Constants ]-------------------------------------------------------
    
    IS_ON           CON     1                       ' for active-high in/out
    IS_OFF          CON     0
    
    
    ' -----[ Variables ]-------------------------------------------------------
    
    
    ' -----[ Initialization ]--------------------------------------------------
    
    Reset:
      LOW LED                                       ' output and off
    
    
    ' -----[ Program Code ]----------------------------------------------------
    
    Main:
      LED = IS_ON
      PAUSE 100
      LED = IS_OFF
      PAUSE 900
      GOTO Main
    
    
    ' -----[ Subroutines ]-----------------------------------------------------
    
    
    ' -------------------------------------------------------------------------
    
    
    ' -----[ User Data ]-------------------------------------------------------
    
  • dennodenno Posts: 221

    JonnyMac, I can't believe I did not see that. I totally forgot to set the (4) pins mentioned to an OUTPUT state. Gosh almighty, how long have I been doing this? Thank you again.

Sign In or Register to comment.