Shop OBEX P1 Docs P2 Docs Learn Events
Max 1270 Help — Parallax Forums

Max 1270 Help

gunstarg10gunstarg10 Posts: 4
edited 2011-02-08 17:22 in Propeller 1
Hi everyone,

I am trying to measure the power consumption of a light 60watt incandescent lightbulb. So far I have a the max 1270 connected to the propeller and a current transformer output connected to the first channel of the ADC. I have modified the code from the obex to get the readings and calculate power. However, I have two issues one is that I am not getting the correct results because it usually reads close to 60watts the first time I run the code but then anytime after that it reads around 70watt. My calculations are to compute the rms since the output of the CT is ac voltage. Second I am having trouble setting a specific number of samples so that if I turn off the light it reads zero. my code should be attached, if anyone can give me any assistance on getting better results I'd appreciate it.

Comments

  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-02-08 15:20
    It seems odd that you'd have the ADC object handle your RMS calculation, and I'm kind of betting that you don't need floating point, either.

    I would simplify the ADC object to limit what it does, though I do like the idea of letting it update a hub variable on a schedule of your choice. If you do that, then you can launch a Spin cog like the one shown below that will take that value and automatically update another hub variable. Just an idea:
    pri rms(vpntr, rmspntr) | t
    
      t := cnt                                                      ' synchronize timing
      repeat
        result := 0                                                 ' clear to start
        repeat 16
          result += (long[vpntr] * long[vpntr])                     ' square samples
          waitcnt(t += (clkfreq / 60) >> 4)                         ' 16 samples @ 60H
        result >>= 4                                                ' average squares
        long[rmspntr] := ^^result                                   ' update RMS
    
  • gunstarg10gunstarg10 Posts: 4
    edited 2011-02-08 17:22
    Thanks for the help. I was able to get it working how I needed it, but you posted some good info. Thanks.
Sign In or Register to comment.