November 22, 2024, 02:47:10 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Using the ADC 0831 Chip with the Allegro Part # ACS755 Current Sensor

Started by samsam, February 07, 2008, 10:55:15 AM

Previous topic - Next topic

samsam

Hi Every One

I had some time to play with the  Allegro Part # ACS755 Current Sensor and the ADC 0831 Chip

The ACS755 Current Sensor has .600 reading @ 0 Amps with a 30 ADC reading and a .600 volts on the ADC 0831 Chip

What I would like to know is how to have the ADC to read 0 and the volts to read 0 with the offset reading of .600 volts from the Current Sensor

Now i did some testing of the Current Sensor and there is a ADC reading of about 3 and a .061 volt reading

What I want to know is how to take every 3 ADC reading for every Amp from the Current Sensor and maybe show the volts also   


Now I know that i could use a look up table but i do not want to do it this way

I would like to do it with the Basic Stamp Math but up to now i have not used it i have look at it in the help file but i do not understand it well enought to do it here

Has any one used the ACS755 Current Sensor and the ADC 0831 Chip and have working code

I want to Thank any one that can help with this

Sam

I Want  Thank You for All Of Your Time And Help

...............In Helping Getting Thing To Work........

JonnyMac

See chapter 28 of my book, StampWorks, which you can download as a PDF from Parallax.  It goes into detail on using the ADC0831 in various modes, including differential which allows you to add a variable offset input that you can use to null your zero-amps reading.
Jon McPhalen
EFX-TEK Hollywood Office

samsam

JonnyMac

Thank You For Your Reply

I will try this again and see if I get the offset to work the way that i want it to work
Sam

I Want  Thank You for All Of Your Time And Help

...............In Helping Getting Thing To Work........

samsam

February 10, 2008, 03:16:25 PM #3 Last Edit: February 10, 2008, 05:48:51 PM by samsam
Hi Every One

I had some time to play with the  Allegro Part # ACS755 Current Sensor and the ADC 0831 Chip

The ACS755 Current Sensor has .600 reading @ 0 Amps with a 30 ADC reading and a .600 volts on the ADC 0831 Chip

I did get ADC to read 0 with the Current Sensor with the offset which is 30 ADC reading

Now i did some testing of the Current Sensor and there is a ADC reading of about 3 and a .061 volt reading

What I want to know is how to take a 3 ADC reading for every  one Amp from the Current Sensor and show them as AMPS
on the DAC 0831 

Now I know that i could use a look up table but i do not want to do it this way

I would like to do it with the Basic Stamp Math but up to now i have not used it i have look at it in the help file but i do not understand it well enought to do it here

Has any one used the ACS755 Current Sensor and the ADC 0831 Chip and have working code

I want to Thank any one that can help with this

Sam

I Want  Thank You for All Of Your Time And Help

...............In Helping Getting Thing To Work........

JonnyMac

Sam,

I'm confused by your question -- others may be too.  Do you want to average three readings together?  If so, you do it like this (note: what follows is psuedo-code, not real code):

  avgValue = 0
  FOR idx = 1 TO 3
    GOSUB Take_Reading
    tmpReading = tmpReading / 3
    avgValue = avgValue + tmpReading
  NEXT


This solution may not be perfect, but it does prevent roll-over of values so it's frequently employed in embedded systems.
Jon McPhalen
EFX-TEK Hollywood Office

samsam

February 10, 2008, 04:29:19 PM #5 Last Edit: February 10, 2008, 05:44:54 PM by samsam
JonnyMac

Thank You for your reply

When using the example from the StampWorks in chapter 28
It shows  3 in the ADC reading to make one amp with the Current Sensor voltage output

With the example it is .019 milvolt for each 1 ADC reading

The Current Sensor is .061 milvolts for each ONE amp that it reads this with a volt meter

Now using the offset the max reading is 224 not 255 as in the example

I want to show 1 amp for every three ADC reading to 50 amps

Current Sensor start with a reading of .600 volts @ 0 AMPS

So with a one Amp on the Current Sensor your reading would be .661 volts

So with 50 amps Amp on the Current Sensor your reading would be  5.00 volts

Sam

I Want  Thank You for All Of Your Time And Help

...............In Helping Getting Thing To Work........

JonnyMac

Okay, if you've got the offset nulled and 50 amps will give you a counts reading of 255, the rest is pretty easy.  Using an 8-bit ADC, 5 volts will return 255 counts.  50 amps divided by 255 is 0.196 amps per count.  The ** operator in PBASIC (1 and 2) allows us to multiply by a fractional value, so we can convert 0.196 to a value for ** by multiplying it by 65536, the result is 12,850.   Your counts to amps equation becomes:

  amps = counts ** 12850

To test the ** operator on your calculator you first multiply, then divide by 65536.  Let's try it with ADC counts = 128.

  128 x 12850 / 65536 = 25

This makes sense, right?  Remember, if you want to run the formula on your Prop-1 or Prop-2, use the ** equation that I show above.

I wrote about math tricks on the Prop-1 and Prop-2 in this thread: http://www.efx-tek.com/php/smf/index.php?topic=49.0
Jon McPhalen
EFX-TEK Hollywood Office

samsam

JonnyMac

The way you explained  to me  How to do some of the Basic Stamp helped alot
Like i said in the first post i look at the help files but did not understand all of the examples well enough to get this to work

This makes sense, right?

  Using an 8-bit ADC, 5 volts will return 255 counts.  50 amps divided by 255 is 0.196 amps per count.  The ** operator in PBASIC (1 and 2) allows us to multiply by a fractional value, so we can convert 0.196 to a value for ** by multiplying it by 65536, the result is 12,850.   Your counts to amps equation becomes:

  amps = counts ** 12850
............ This only gave me 45 amps at full scale     For each amp was a little off  but close


To test the ** operator on your calculator you first multiply, then divide by 65536.

You explain this well enough that i came up with the same answer that you have here

I had to adj for the offset because there is .600 volt @ 0 amps so there is only 225 steps

so i used this

amps = counts ** 14630  which give me at 51 amps at full scale for each amp was almost on it

You gave me  the tools to understand how to do this

I will post the project when i  put both ADC 0831 and the  Current Sensor on the same board

this will be a few weeks ' =========================================================================
'
'   File....... SW21-EX28-ADC0831-Simple.BS2
'   Purpose.... Servo control and positioning with a potentiomenter
'   Author..... (C) 2000 - 2005, Parallax, Inc.
'   E-mail..... support@parallax.com
'   Started....
'   Updated.... 01 SEP 2005
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' This program deomstrates reading a variable voltage with an ADC0831
' analog-to-digital convertor chip. This program uses a Vref input of
' 5.000 volts (Vdd) for a bit resolution of 19.6 millivolts.
'
' Jon Williams
' EFX-TEK
'
' Okay, IF you've got the offset nulled and 50 amps will give you a counts reading of 255,
' the rest is pretty easy.  Using an 8-bit ADC, 5 volts will RETURn 255 counts.
' 50 amps divided by 255 is 0.196 amps per COUNT.
' The ** operator in PBASIC (1 AND 2) allows us TO multiply by a fractional value,
' so we can convert 0.196 TO a value FOR ** by multiplying it by 65536,
' the result is 12,850.   Your counts TO amps equation becomes:amps = counts ** 12850
'
' To test the ** operator ON your calculator you first multiply, THEN divide by 65536.
' Let's try it with ADC counts = 128. 128 x 12850 / 65536 = 25
' This makes sense, right?  Remember, IF you want TO run the formula ON your Prop-1 OR Prop-2,
' use the ** equation that I show above.

' I wrote about math tricks ON the Prop-1 AND Prop-2 in this thread:
http://www.efx-tek.com/php/smf/index.php?topic=49.0

'--------------------------------------------------------------------------------



' -----[ I/O Definitions ]-------------------------------------------------

CS              PIN     0                       ' chip select (ADC0831.1)
Clock           PIN     1                       ' clock (ADC0831.7)
DataIn          PIN     2                       ' data (ADC0831.6)


' -----[ Constants ]-------------------------------------------------------
' The Current Sensor has an offset voltage of .600
' The Current Sensor has  .061 Volts for each (ONE) Amp that it reads
' The ADC 0831 has 255 steps but because the off set voltage is .600 volts
' The ADC only has 225 steps for 0 to 5.00 volts
' The reading for each amp is a little off but not by much which i can live with
' I can adj the counts # some to make up for this but changes the span a little
' We will see what happen when i hook up the current sensor to the ADC and try to it
' All i have been doing right now is this example in Stamp Works chapter 28
' the second example in that chapter

counts         CON    14630


' -----[ Variables ]-------------------------------------------------------

result          VAR     Byte                    ' result of conversion
Amps            VAR     Byte                    ' millivolts


' -----[ Initialization ]--------------------------------------------------

Reset:
  DEBUG CLS,                                    ' create report screen
        "ADC....  ", CR,
        "Amps...  "


' -----[ Program Code ]----------------------------------------------------

Main:
  DO
    GOSUB Read_0831                             ' read the ADC
     Amps = result ** counts                     ' convert to millivolts

    DEBUG HOME,                                 ' report
          CRSRXY, 9, 0, DEC result, CLREOL,
          CRSRXY, 9, 1, DEC Amps DIG 1,
                        " ", DEC1 Amps


    PAUSE 100
LOOP


' -----[ Subroutines ]-----------------------------------------------------

Read_0831:
  LOW CS                                        ' enable ADC
  SHIFTIN DataIn, Clock, MSBPOST, [result\9]    ' read ADC
  HIGH CS                                       ' disable ADC
  RETURN
Sam

I Want  Thank You for All Of Your Time And Help

...............In Helping Getting Thing To Work........