Shop OBEX P1 Docs P2 Docs Learn Events
Trying to incorperate a calibration function into a BS2 program. — Parallax Forums

Trying to incorperate a calibration function into a BS2 program.

ihmechihmech Posts: 179
edited 2009-09-12 01:28 in BASIC Stamp
I am trying to make a tool for testing a machine.· I need this tool to take the place of a hall effect sensor and provide a signal from the BS2 in·place of the sensor.· The trouble I am having is trying to figure out how to calibrate the tool to the machine.· I need to provide a pulse that I can vary manually with a pot until the machine monitor reads say..."5MPH".· I also need to store the calibration value into EEPROM, for my program to provide an accurate pulse at user selectable MPH using the calibration value.· I have thought about using a 555 timer circuit to provide a pulse that the machine moniter can read at the same time as the BS2 to provide the calibration value.· I just need to save the calibration value to the EEPROM and then be able to get the BS2 to provide the pulse based on the calibration value.

If anyone has any ideas it would be appreciated!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-06 20:52
    Read the chapters in the Stamp Manual (or the equivalent in the Stamp Editor help files) on the READ, WRITE, and DATA statements. You'd use a DATA statement to provide an initial value and a WRITE statement to store a calibration value. READ statement would read the stored value either to re-calibrate starting at that value or for the actual testing. The calibration value would remain there until changed by the program or until a new program is loaded.
  • ihmechihmech Posts: 179
    edited 2009-09-06 21:36
    Thank you, I'll start working on it!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-09-06 23:11
    ihmech,

    It wasn’t clear to me after reading your message how this system needs to work. I have a few questions for which the answers may help others help you…

    1) Is the BASIC Stamp 2 going to be part of the tool you are trying to create?
    2) If so, how does this tool get the data it needs to self-calibrate?
    3) What is the range (pulse-width) of the pulse the BS2 needs to generate?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    50 72 6F 6A 65 63 74 20 53 69 74 65
    ·
  • ihmechihmech Posts: 179
    edited 2009-09-07 00:15
    Thank's for the questions Chris! I hope this helps explain things better.

    1) Is the BASIC Stamp 2 going to be part of the tool you are trying to create?

    Yes, it is going to be a part of the tool.

    2) If so, how does this tool get the data it needs to self-calibrate?

    I am going to make a CAL menu and what I need the tool to do is to provide a pulse rate to the machine controller/monitor, but the rate needs to be adjustable while reading the machine monitor to set a speed of 5MPH (5mph is just an example) on the monitor. After a desired calibration speed is displayed on the monitor, I need to save the adjusted pulse rate to the EEPROM to be used in the main program in the future.

    3) What is the range (pulse-width) of the pulse the BS2 needs to generate?

    The tone wheels have 48 teeth on them and I took the amount of teeth with the circumfence of the wheel and roughly figured out the pulse width. The max pulse width I came up with on one machine was a max of 63ms@ 8MPH and a min of 32ms at 4MPH. This covers the MPH range I need for testing. Once a calibration value is stored, I need the program to take that value and the user input for the desired MPH and output the correct pulse for the desired MPH.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-09-07 02:36
    ihmech,

    It does explain that the BS2 is the tool and needs to generate the pulses. There are still some details missing though, such as repeat rate. The BASIC Stamp 2 can generate pulses with a resolution of 2 uS with a maximum pulse width of 131 mS. But does the pulse need to repeat? If so, what is the repeat rate? The repeat rate will greatly affect if the pulse rate is achievable. Also, it will affect being able to set/change the pulse width on the fly. Speaking of which, is the pulse rate constant or variable?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    50 72 6F 6A 65 63 74 20 53 69 74 65
    ·
  • ihmechihmech Posts: 179
    edited 2009-09-07 04:07
    I hope this helps....

    The pulse rate needs to be an on/off pulse that repeats infinetly. It only needs to be adjustable during calibration. What needs to happen is that the pulse rate needs to be dialed in to achieve the 5MPH on the machine monitor. Kinda like when you tune an old radio. After the tool has been "tuned" I planned on having a save button to store the value.

    I've been thinking on my problem and the only idea that I have had is using a 555 timer circuit with a pot. I thought that I could use the 555 to generate a pulse rate that I can manually adjust to get the MPH I want displayed on the machine monitor. I was thinking of connecting the output of the 555 circuit to the machine and a pin (pin 12 for example) on the BS2 I thought I could write the CAL program to turn on the 555 timer, then I could manually adjust the pulse until I get the desired speed displayed on the machine monitor and use PULSEIN on pin "12" to store the value in a variable, then use a save button to write the value to a data location in the EEPROM. After pressing save, the program would stop the 555 circuit and on the same pin "12" output the infinite pulse rate to the machine.

    I don't know if my idea will work...I have a few 555 ICs, but can't seem to find them. So, I have not been able to test my idea yet.
  • ihmechihmech Posts: 179
    edited 2009-09-07 04:21
    Here is a picture of what I was thinking of....
  • GeorgehaneeGeorgehanee Posts: 1
    edited 2009-09-07 04:29
    That's great this page have a nice discussion....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Acne
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-07 05:05
    One way to make a continuous sequence of pulses using just the Stamp is to use a PULSOUT statement to produce the on pulse and a PAUSE statement to produce the off pulse. You haven't said what the actual width of the pulse needs to be. You can have two pushbuttons, one for up and the other for down, something like this:
    pulsePin           PIN   1       ' output on I/O pin #1
    buttonUp          PIN   2       ' button to Vdd, 10K resistor to Vss, increments time between pulses by 1ms, maximum 70ms
    buttonDn          PIN   3       ' button to Vdd, 10K resistor to Vss, decrements time between pulses by 1ms, minimum 25ms
    buttonEnd        PIN   4       ' button to Vdd, 10K resistor to Vss, ends program with value output to PC using DEBUG
    pulseWidth       CON  50     ' pulse width in 2us units
    initialTime        CON  47     ' initial time between pulses in 1ms units
    spaceBetween  VAR  byte   ' actual time between pulses in 1ms units
      low pulsePin                                    ' set initial state of output pin
      spaceBetween = initialTime
    mainLoop:
      pulsout pulsePin,pulseWidth              ' produce one pulse
      pause spaceBetween                        ' wait specified time between pulses
      if buttonUp = 0 and buttonDn = 0 and buttonEnd = 0 then goto mainLoop
      if buttonUp = 1 then                            ' was up button pushed?
         if spaceBetween < 70 then spaceBetween = spaceBetween + 1 ' maximum 70ms
      elseif buttonDn = 1 then                      ' down button was pushed
         if spaceBetween > 25 then spaceBetween = spaceBetween - 1 ' minimum 25ms
      else                                                   ' end button was pushed
         debug "pause time was ",dec spaceBetween,"ms",cr
         stop
      endif
    waitForIdle:                                          ' continue to generate pulses while
      pulsout pulsePin,pulseWidth                 '   waiting for both pushbuttons to
      pause spaceBetween                          '   be released
      if buttonUp = 1 or buttonDn = 1 or buttonEnd = 1 then goto waitForIdle
      goto mainLoop
    

    Post Edited (Mike Green) : 9/7/2009 5:17:59 AM GMT
  • ihmechihmech Posts: 179
    edited 2009-09-07 05:38
    I should have not been saying pulse width, sorry...I should have been saying frequency. I'm still teaching myself stamps and trying to build something at the same time. A guy I work with came back from training on this machine and told me that the instructor said that some shops had an old signal generator that was used for checking dash modules years ago and that it could be used to supply a signal in place of the wheel speed sensor. This would make the machine controller think that the machine was moving and it would allow everything to work as if the machine was in motion. We did not have the signal generator in our shop, so I thought I could come up with something better and more user friendly.
  • ihmechihmech Posts: 179
    edited 2009-09-12 01:28
    I think I got something figured out, I just have to do some building now. Thank's guys for all of your help.
Sign In or Register to comment.