Shop OBEX P1 Docs P2 Docs Learn Events
Wind Turbine Project Help — Parallax Forums

Wind Turbine Project Help

ZouLouZouLou Posts: 6
edited 2011-04-26 00:53 in BASIC Stamp
Hi, I am very new to the Basic Stamp community and new to microcontrollers overall. I have worked through most of the projects in the "What is a Microcontroller?" book to get a good simple feel for the PBasic language.

For my college capstone project, we are building a variable pitch wind turbine hub for a very small scale wind turbine (1.28m blade diameter). I am using the BASIC Stamp BOE board as the brains of the machine. I have a wind speed sensor and a rotary encoder to measure the two wind components.

I found some example code written on here from March of last year that should work with my specific wind speed sensor. It can be found here:

http://forums.parallax.com/showthread.php?120507-I2C-eagle-Tree-Airspeed-sensor

So I would like to say thanks to Istha Powron if he is still around.

The encoder is where I am running into trouble. I have been told to look into both the COUNT and PULSIN commands, but have not had much luck. I apologize for any dumb comment or question, I am a mechanical engineer and I am basically electronically illiterate.

These two sensor inputs will be used to calculate the desired angle of attack. This information will then be sent out in TTL format (terminology?) to a board that will convert it from TTL to RS485. This signal will then finally reach the motor control board which controls a motor with a built in encoder.

I would prefer to get the Basic Stamp program squared away before trying to figure out the control board. I have written a little bit of lousy code that I attached below.
' {$STAMP BS2px}
' {$PBASIC 2.5}

SDA PIN 0              ' I2C SDA pin
SCL PIN 1

addr     VAR Word      ' internal address
result   VAR Byte(2)   ' array for returned value
windpara VAR Word      ' wind from actual wind
rpm      VAR Word      ' revolution of generator
windperp VAR Word      ' wind from rotation
B        VAR Word      ' angle between resultant and rotation

DO

    PAUSE 1000

    addr = $EA
    I2CIN SDA, addr, [STR result\2]

    windpara = result(0)*256 + result(1)

    PAUSE 1000

    rpm = ?

    windperp = rpm*0.33

    PAUSE 1000

    B = 

LOOP

Any help is greatly appreciated. Thanks in advanced.

- Kyle

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2011-04-20 21:31
    ZouLou,

    "The encoder is where I am running into trouble" - can you provide more information on the encoder? We need to know the type of signal produced in order to determine the RPM.
  • ZouLouZouLou Posts: 6
    edited 2011-04-21 10:13
    Its a capacitive incremental encoded. It is specifically CUI AMT103 it can be found on digikey.com. Thank you for the response.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2011-04-21 22:05
    ZouLou,

    According to the data sheet, I would start out with the lowest resolution of 48ppr and work up from there if necessary. The output is quadrature with the "A" channel leading the "B" channel if the rotation is clockwise. The opposite is true if the rotation is counter clockwise. I'm not sure even at the lowest resolution though how well the Basic Stamp II can handle the quadrature without some external circuitry. Although the Propeller can do quadrature decoding, I think it's overkill for this application. A single IC (74HC73 - Dual JK flip-flop) will work if you need to determine the rotation direction (See attached schematic)

    If however you don't care which direction the rotation is and you just want to know the rpm, you can simply look at one of the channels "A" or "B" it doesn't matter and you can forget the attached schematic.

    Assuming you set the resolution to 48ppr and you used the COUNT function for 1 second, the code format would look like this....

    COUNT {pin}, {Word Varaible}, {Duration}

    Where:
    pin - is the pin you select on the Basic Stamp II for the input pulse
    Word Variable - Is a variable you define that will store the returned value from the COUNT
    Duration - Is in ms, so 1000 ms = 1 second (you can experiment with your own values here)

    To calculate speed, you would take the returned {Word Varaible} and divide by your ppr. In this case your ppr is 48 to get a rps (revolutions per second) reading. Multiply the rps by 60 to get rpm (revolutions per minute)

    CUI AMT103 datasheet reference:
    http://www.amtencoder.com/LinkClick.aspx?fileticket=F2vqx8zhehE%3d&tabid=216
    1024 x 716 - 96K
  • ZouLouZouLou Posts: 6
    edited 2011-04-25 00:37
    Wow thank you very much that is going to be so helpful. On this design direction doesn't mater because how the blades are oriented the wind turbine would only spin one way anyway. Thank you again for that bit of advice on this project.

    My next task is to get it to output my final result in TTL. I will work on some more code tomorrow, but thank you very much again.

    -Kyle
  • ZouLouZouLou Posts: 6
    edited 2011-04-26 00:53
    The RPM advice was very helpful. I now have it running and outputting an RPM number to the debug window. It seems to be running fine now so that help is much appreciated.

    The issue I am having now is with my wind speed sensor. It communicates in I2C and the code I have is for a BS2px which has the built in I2C command I2CIN, but I am just using the basic BS2 from the BOE Kit which lacks this command. I have read multiple places how it is still very possible with the BS2 but have not been able to successfully accomplish it.

    The sample code I am referring to can be found here:
    http://forums.parallax.com/showthread.php?120507-I2C-eagle-Tree-Airspeed-sensor

    Information about using the sensor I am using in 3rd party mode can be found here:
    http://www.eagletreesystems.com/support/manuals/microsensor-i2c.pdf

    And finally the information I have been reading about using a BS2 with I2C can be found here:
    http://www.lennard.net.nz/electronics/i2c.html

    Thank you again for the help. The small success I had with the RPM reading was a great confidence booster.

    - Kyle
Sign In or Register to comment.