Shop OBEX P1 Docs P2 Docs Learn Events
Wiring AD5220 fo a 7-segment display — Parallax Forums

Wiring AD5220 fo a 7-segment display

Matt BryantMatt Bryant Posts: 5
edited 2009-10-20 02:52 in BASIC Stamp
I have a 7-segment display wired on a BASIC Stamp Homework Board.· I am attempting to run a numerical loop on the display with a button to stop the loop and when the loop is stopped use a potentiometer to cycle through the numbers.· How would I wire the microcontroller to the display?· I have looked at pin layouts and got confused.·freaked.gif Thanks in advance for the responses.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-10-05 02:49
    Show us how you have it wired and include a flowchart/diagram of the steps you want the program to take.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Matt BryantMatt Bryant Posts: 5
    edited 2009-10-05 22:24
    I have the 7-segment display wired correctly, I have tested this. The display loops through the HEX digits 0-F. I want to wire a pushbutton to start and stop the loop. When the loop is stopped, I want to use a potentiometer to cycle through the digits individually. I believe I can do the coding, it is the wiring of the controller chip that I am having problems with. I have looked at the pin layouts for the AD5220. Unfortunately, the only chips I have experience with are the 7400 series. The pin layout for this chip is completely new to me. I apologize for not including a flowchart, I do not have a program for that. Thank you for your help. If you need more information, please let me know.
  • FranklinFranklin Posts: 4,747
    edited 2009-10-05 22:39
    You're looking at that chip backwards. It takes a switch and button as inputs and outputs a resistance, not what you want to happen. You will need to find a different way to do it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Matt BryantMatt Bryant Posts: 5
    edited 2009-10-05 23:45
    Is it possible to wire a potentiometer and a pushbutton to a 7-segment display using chip AD5220?· I am very new to this.·Thank you.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-10-06 00:14
    With a (any) BS2 you could work out a circuit whereby you could read the pot and establish·a value to display on your 7-segment without any ADC.· You would use the RCTIME command.· Wiring in a pushbutton is no problem either, Stampers do it all the time.
  • Alan C.Alan C. Posts: 1
    edited 2009-10-16 17:28
    Hello there,

    I am in the same class at Matt and we are running into some problems, as he stated before.·Let me start from the beginning to help those fully understand what we are trying to accomplish.
    This may seem very simple to some, but this is our first time·dealing with·one of these... so please be gentle confused.gif

    -We had the idea to·make·the 7 segment display count in hexadecimal numbers: 0-F
    -We wired up the display and wrote the code for it to work
    -Added in a loop to make it·a continuous count.

    We got that working just fine! The problem we are facing now is that we are trying to add in a few things to make it have that "WOW" factor to ensure us the A+.
    Trying to add in a button so that when we press it, it starts the counting, then press it again it stops... what we WANT to do is make the button stop it, and then incorporate a potentiometer to filter through the numbers. Before we get to the potentiometer part we need to make the button work. We have it so when it is pressed it starts, but it wont stop once its pressed again. I know we need some form of IF-AND-ELSE statement of some kind, but im having a hard time finding one... and the ones I have come accross are not what we need.

    So all in all, im at a loss. No clue where to go next and the semester is coming to a close!
    If anyone has any idea where to go next, please let me know [noparse]:)[/noparse]

    Thanks,

    Alan
  • mikedivmikediv Posts: 825
    edited 2009-10-16 18:02
    Alan it would be a lot easier for people to help you if you guys post your full code and schematic that way we can actually see what you are doing I don't think it will be hard at all for the people here but we need to see your work.
  • Matt BryantMatt Bryant Posts: 5
    edited 2009-10-18 17:39
    The code we have as of now is as follows:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    ' Pattens of 7-Segment Display to create numbers 0-F
    DO
    DEBUG ? IN3

    IF (IN3 = 1) THEN


    OUTH = %00000000
    DIRH = %11111111

    ' BAFG.CDE
    OUTH = %11100111
    PAUSE 1000
    OUTH = %10000100
    PAUSE 1000
    OUTH = %11010011
    PAUSE 1000
    OUTH = %11010110
    PAUSE 1000
    OUTH = %10110100
    PAUSE 1000
    OUTH = %01110110
    PAUSE 1000
    OUTH = %01110111
    PAUSE 1000
    OUTH = %11000100
    PAUSE 1000
    OUTH = %11110111
    PAUSE 1000
    OUTH = %11110110
    PAUSE 1000
    OUTH = %11110101
    PAUSE 1000
    OUTH = %00110111
    PAUSE 1000
    OUTH = %01100011
    PAUSE 1000
    OUTH = %10010111
    PAUSE 1000
    OUTH = %01110011
    PAUSE 1000
    OUTH = %01110001
    PAUSE 1000
    DIRH = %00000000

    DIRH = %00000000
    ENDIF
    LOOP
    END
  • Chuck ThomasChuck Thomas Posts: 39
    edited 2009-10-18 21:25
    Alan,

    Just a real quick look. When are you reading the input from your switch to stop the program.
    Here is what I see.
    Display number, wait 1 second. and repeat.

    You either want to read the switch before or after the pause 1000.

    Better yet put it into a for next loop that can read the input pins while the pause between number takes effect.
    Make this a subroutine and run between each number.
    display number 1
    gosub check
    display number 2· ......

    check:
    For I = 1 to 100
    · read input pin
    ··· if triggered
    ····· gosub triggered routine.
    ··· else
    · pause 10
    next
    return

    You could also increase the for next to 1000 and the pause to 1. This would give you slightly more than a 1 sec pause but increase the ability to see a triggered pin.

    Chuck


    Post Edited (Chuck Thomas) : 10/18/2009 9:31:12 PM GMT
  • Matt BryantMatt Bryant Posts: 5
    edited 2009-10-19 23:51
    Thanks for the speedy response. Unfortunately I am very new to programming. I don't fully understand the following code: "For I = 1 to 100"
    When I enter in this code, I get the error 'Expected a variable.' If you could please explain this line of code, it would be greatly appreciated.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-10-20 02:16
    'Expected a variable' means you need to declare the variable in question -- I.· So, add a/the line:· I· VAR· Byte
  • Chuck ThomasChuck Thomas Posts: 39
    edited 2009-10-20 02:52
    Matt,

    Page 55 of the What's a Microcontroller will explain a for..next loop or use the help menu for a better explaination.


    For I = 1 to 100················· "I" is a variable. It must be declared normally at the top of the program. That would solve your error.
    ·······································In this case "I" can be a byte. A Byte can be a number up to 255.
    ······································· I VAR Byte
    ······································· If you use a pause of 1 and an if..then of 1000 then "I" needs to be a Word
    · read input pin··················· 'This not the actual command this just says what needs to be done.
    ······································· Look up INA in the help menu or page 78. It will also explain variables.
    ··· if triggered····················· Look up if..then...else page 81 or in the help menu.
    ····· gosub triggered routine.·· look up gosub page 206 or in the help menu
    ··· else
    · pause 10
    next

    You should now have enough information to complete your project. If you have questions after reading the book and working out the book examples come back and post follow up questions.

    Chuck
Sign In or Register to comment.