You are here

Barc Assembled | Cypress Semiconductor

Barc Assembled

Barc (finally) got his nose back this week. I replaced the ugly yellow wire loops with some copper tape and added an Adafruit IR sensor that pokes out of his mouth. Subtle stuff! It is way easier to work on this guy now he is stretched out on one level. In my program I am going to detect the presence of a hand via the IR or CapSense sensors. I started with the new IR sensor, which is controlled via three wires.

Barc assembled...

 

The red wire is power and black is ground. I could just hook them directly to the power rails on the proto board but, since I may decide to turn the sensor on/off in future (and because I soldered a header to the wires), I am just connecting them to PSoC pins and will drive them from my program. The white wire is the analog input, which I am connecting to the PSoC ADC.

Barc ADC and I2C

 

The I2C component (set to 400kbps data rate) is there so that I can send the ADC data to the PC via the kitprog (more in a while). I configured the ADC to average out noise and give me a steady stream of results. I only need one single-ended channel with a range of 0.0V to 5.5V that returns an averaged result of 256 samples.

Barc ADC Configuration

 

I then chose pins P1[2], P1[3] and P1[4] for the sensor (ADC), ground and power respectively. The I2C goes on P4[0] and P4[1]. My design was ready and I just needed to write a little code. I was not sure how sensitive the sensor would be so I decided to use our Bridge Control Panel to plot the ADC values in real time. The following code turns on the IR sensor and sets up the ADC.
 

    Pin_IR_GND_Write( 0 );                              // Make sure ground is low
    Pin_IR_Power_Write( 1 );                            // Turn on the sensor
    CyDelay( IR_SENSOR_SETTLE_TIME );                   // Allow time for sensor output to be valid
    ADC_IR_Sensor_Start();                              // Turn on the ADC
    ADC_IR_Sensor_StartConvert();                       // Start sampling (free running)

This turns on I2C and sets it up to communicate across the kitprog I2C-USB bridge to the PC.

    #define I2CBUFSIZE  (2)
    static uint8 i2cbuf[I2CBUFSIZE];
    EZI2C_Start();                                      // Turn on I2C (over kitprog bridge)
    EZI2C_EzI2CSetBuffer1( I2CBUFSIZE, 0, i2cbuf );     // Set up the buffer for communication

I then put this code into the main loop. It just samples the ADC and writes the 16-bit values into the I2C buffer. The EZI2C component does the hard part - in the background it sends the buffer up to the Bridge Control Panel (BCP) software.

    int16 range = 0;                                    // ADC value

    for(;;)
    {       
        /* Get an ADC value from the distance sensor and convert it to millivolts */
        if( ADC_IR_Sensor_IsEndConversion( ADC_IR_Sensor_RETURN_STATUS ) )
        {
            range = ADC_IR_Sensor_GetResult16( IR_SENSOR_CHANNEL );
            range = ADC_IR_Sensor_CountsTo_mVolts( IR_SENSOR_CHANNEL, range );
            
            i2cbuf[0] = ( range >> 8 ) & 0xFF;
            i2cbuf[1] = ( range >> 0 ) & 0xFF;
        }

    }

Once I had this programmed I started up the BCP, selected the kitprog connection, and configured I2C to be 400kHz so that it matches the component speed. I was almost ready to look at the signal from the IR sensor. The PSoC sends 2 bytes and I needed to pack them back into a 16-bit value. So I created a variable, gave it the name "range", and made it 16-bits wide.

Barc EZ-I2C range variable setup

 

Back in the editor I write a command to read ('r') from address "08" into byte 1 "@1range" and byte 0 "@0range" of the range variable:

r 08 @1range @0range p

When I press the "Repeat" button and switch to the Chart view it shows me the ADC output in real-time.

Barc ADC sensing proximity

 

You can see that there is a floor of about 1800mV and that, as I moved my hand in and out of range, the value peaked at about 3300V. There are two peaks because I moved my hand from afar, all the way into Barc's nose, and then back out again. If you get too close the IR sensor goes "blind" and the voltage drops. This is really good information because I now know that I can detect the presence of a hand by simply comparing the ADC voltage with a value of about 1800V plus 100mV for safety. That's a simple piece of code that I will add in a week or so... when I re-tune the CapSense sensors and create a state machine for moving the dog around.

Unfortunately, as you may have guessed, Barc missed his flight to Shenzen for Maker Faire. There was a bit of a mix up about when he needed to be ready and after all the arguing stopped there was just a really disappointed dog. So we promised ot take him back to Germany for Embedded World next year...

Comments

ankurpathania53_2921056's picture

arc missed his flight to Shenzen for Maker Faire. There was a bit of a mix up about  Top Form Templates when he needed to be ready and

after all the arguing stopped Free Printable Invoice Template there was just a really BMI chart templates disappointed dog. 

ankurpathania53_2921056's picture

 That's a simple piece of code that I Employee Attendance Sheet Tracker will add in a week or so...  Letter To Verify Employment when I re-tune the CapSense sensors   resignation letter samples for teachers and create a state machine for moving the dog  URL around.

solomondaniel308_2809456's picture

This sort of package passes on an exceptional arranged assortment of movement for understudies, This is the regular hazard looked by each product design. Taking a shot pro essay at different stages is a frenzied errand and it was the significant issue looked by each designer.

stellaban.co.uk_2945901's picture

This is the ordinary danger looked at each product design.  there was a chunk of a mix up while he needed to be prepared and after all the arguing stopped. this is honestly accurate facts due to the fact I now recognize that I Pay Someone To Do my Essay can stumble on the presence of a hand by using genuinely evaluating the ADC voltage with a price of about 1800V plus 100mV for protection.

ellinoah.co.uk_2945981's picture

That pokes out of his mouth. subtle stuff! it's far way simpler to work in this guy now he's stretched out on one degree. Essay Writing Helper - EssayHelpPros.co.uk I configured the ADC to average out the noise and deliver me a regular circulate of results. I most effective need one single-ended channel with quite a number zero.0V to five.5V that returns an averaged end result. This kind of bundle passes on an extremely good organized assortment of motion for understudies,

olive.ethan101.co.uk_2945996's picture

To common out the noise and deliver me an ordinary circulate of outcomes. This type of package passes on an awesome organized assortment of movement for understudies, that is the regular threat looked by TrueEssayHelp | Essay Help Online UK means of every product layout. his is virtually excellent data due to the fact I now recognise that I can detect the presence of a hand by way of without a doubt comparing the ADC voltage

KellimWorthington091_2958006's picture

I have found a masterpiece of paper that is very beneficial for me because i am the student of engineering and I have got an assignment of physics and this article is very useful for me. Write My Assignment. Thanks. 

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.