psoc - voltage(adc) to freq converter tutorial (graphite piano)

30
The Goal of this is tutorial is to give you a tiny taste of using PSoC Express(almost) Code-Free software.

Upload: brian-german

Post on 29-Sep-2015

25 views

Category:

Documents


0 download

TRANSCRIPT

  • The Goal of this is tutorial is to give you a tiny taste of using PSoC Express

    (almost) Code-Free software.

  • What is a PSoC MCU? and what is PSoC Express Software?...and why are they so unique?

    The Geniuses at Cypress have made a type of MCU called a PSoC (Programmable System On Chip) that has the amazing ability to have configurable Analog and Digital Blocks (like LEGOs).

    If you want a pressure sensor as an input, for example, they have all the code done in a Device Driver for you.

    If you want an LED to light at 10psi, and a buzzer to sound at 20psi, just select those output drivers and use a valuator to decide what conditions you want it to meet (this part can be tricky if you do not know basic C commands).

    Hopefully, you will see what I mean

    Cypress now offers PSoC Express software (for free) that lets you do a lot without needing to know the driver code, initialization code, etc.

  • For this training you will make a Voltage to Frequency Converter (Or Graphite Piano) using an 8-pin PSoC MCU.The Pitch on the Speaker changes with the Voltage Input

  • Stepping through this tutorial will quickly get you familiar with the simple flexibility of programming a PSoC MCU (without needing to know C or assembly language) using PSoC Express.

    This was done with version 2.20 of PSoC Express.

  • You will need:PSoC Express 2.2 or an identically functioning upgrade.1- CY3210-PSoCEVAL1 board with PSoC MCU1- MINIProg USB Programing adapter1- small speaker (8 ~ 16 Ohm)1- 0.1uF Cap1 each- 1M and 510 Ohm Resistor3- Test leads to connect to paperA relative or friend, with children, to give this to- (that you need to repay for buying your kid a musical toy that drove you crazy).

  • Open 'PSoC Express'. Close the Design Catalog that pops up.Save the file with your name

  • Drag an Input from the bottom as shown.Choose a Pot and leave it labeled Input1...This will give you an Analog to Digital ADC Input.Read the 'Software Interface' Part of the Device Driver Description

  • Add an Output and choose a 'Variable Freq & Duty Cycle, 10mA, High Side'...Read the 'Software Interface' Part of the Device Driver Description

  • ...Rename it 'Speaker'. Set the 'Base Freq' to 500Hz (higher freqs are really annoying)

  • As you read in the 'Software Interface', the Pot input driver delivers a value from 0 to 100, based on what voltage is on that pin (0 to 5V here).

    The 'Speaker' output requires a value of 50 to 200 to be sent to it and will directly multiply the 'Base Freq' you entered by 50% to 200%.

    To bridge these two we will use a 'Valuator' to condition the signal value so the output can use it.

  • Add a Valuator, Name it 'Multiplier', Choose 'StatusEncoder'...

  • Click on the first box to start entering this logic...This will condition the Input1 value 0 ~ 100 to a 50 ~ 200 value that the 'Speaker' output can use.

  • Right Click on 'Speaker' and Click on 'Transfer Function'. Accept the default of 'PriorityEncoder' and enter this logic...The first line 'if Multiplier >= 180 then 0' shuts off the output when any signal above 4.5V is at the input.

    This is done with the 1M Ohm pullup resistor on the input that keeps the input (and sound) from going all over when the lead is not touching the graphite trace. Try removing it when its running later.This is the | key

  • 'if 1 then (Multiplier
  • You have to save your project before you can proceed.

    This is sweet you can test your code before you build it. Click on the tab labelled 'Simulation'

  • Move the Input1 slider up a bit and release.

    Notice how the Multiplier value and Speaker value stay the same until you pass 25% on the slider.

  • Raise the slider more (and release) and see the values change just like you told them to.

  • Bring it further and notice how the Speaker value drops to 0 when the slider exceeds 90% (again, this keeps the speaker off via the pull-up resistor until the input reads a lower voltage)

  • Now click 'Build'...

  • Select the target PSoC IC, (the CY8C24123A 8-Pin) and select 'Free Run' for Sample Rate

  • With a PSoC MCU, You can often choose where you want your pins (Can you say flexible?!)

    For this training, bring the Input to Pin 1 and the Speaker output to pin 3, and proceedThe software is now compiling all the code for you- generating the HEX file as well as C, so if you know C and care to edit the code beyond what you can do in Express, you can.

  • This board is designed for 28pin devices but has been modified for an 8-pin IC this way

  • Connect the USB 'MINIProg' programming adapter to the target board.

    Click 'program'...

  • Click on Port and select 'MINIProg...' Now hit 'Connect'

  • Click on Program, it should soon say 'Programming Succeeded'

  • Hit 'Toggle Device Power' (2) to power the circuit via the USB port.

  • Take a sheet of paper and draw a heavy line (1/4' thick) with a pencil. Clip your Vcc and GND to the ends and use the Input test clip to play the notes.

    (you can also hold the Input clip in one hand and touch the line with your other hand)

    Add thick lines off of it at spots that have more pleasant notes if you wish (see below).

  • Here is the schematic to reference again. Increasing the 510 Ohm resistor will reduce the volume.

  • As you can imagine, there are endless possibilities with a PSoC MCU.

    This software allows even seasoned programmers to save lots of time as well.

    PSoC Express generates a 'C' file that has all the input and output drivers written, so the code can be further tweaked easily in the PSoC Designer software (if, of course, you are fluent with it) and finished quickly.

  • Please

    1. Close the PSoC Express program

    2. Fill out the Training Questionnaire 3. Get someone who has not run through this yet 4. Have a great day! (this part is mandatory- be glad you didnt have to ask Want fries with that? today)