Skip to main content
  • Press & News
  • Contact Us
  • Login
  • Register

Main menu

  • Technology
  • Business
  • Downloads
  • Community
  • Buy
Join Forum Blog Projects Social 

You are here

Home » Forums » Software - Apps, IDE

Analogue i/p Vs web server

5 posts / 0 new
Log in or register to post comments
Last post
Tue, 02/21/2012 - 22:24
#1
Creed
Offline
Joined: 09/15/2011
Posts: 13
Analogue i/p Vs web server

Hi all. I have a proximity sensor (MB1010) connected to analogue i/p 1 and a simple piece of code to turn on a LED when an object comes within a proximity. This works fine. Until I open the webserver on my laptop to view the analogue input that is. As soon as the webserver is open the analogue i/p starts to fluctuate. Just wondering why this might be happening?

Top
  • Log in or register to post comments
Wed, 02/22/2012 - 10:20
#2
simmartin
simmartin's picture
This Cat's on a Hot Tin Roof

Online
Joined: 05/03/2011
Posts: 341

It could be related to lot of things.

First of all, can you attach a cheme of your analog connection?

Are you using the IDE 2.1?

This Cat's on a Hot Tin Roof!

Top
  • Log in or register to post comments
Wed, 02/22/2012 - 17:00
#3
Creed
Offline
Joined: 09/15/2011
Posts: 13

Hi. Thanks for the reply. Sorry for using paint, it was the easiest software at hand for such a simple schematic. The code I used is as follows:

 

.............................................................................................................................

#include "taskFlyport.h"

void FlyportTask()
{
WFConnect(WF_DEFAULT);
while (WFStatus != CONNECTED);
UARTWrite(1,"Flyport connected... hello world!\r\n");

int sensor_in;
 
while(1)
  {
  sensor_in = ADCVal(1);
 
    if( sensor_in < 200 )
    {
    IOPut(d4out, off);
    }
    else{
    IOPut(d4out, on);
    }
}
}

.............................................................................................................................

Its very simple and works fine when the webserver is off but the analogue input goes nuts when the webserver is open and the LED starts flashing. I'm probably missing something very simple. And yes I am using the newest IDE 2.1.

Thanks for the help.

Creed. 

AttachmentSize
TEST.JPG12.67 KB
Top
  • Log in or register to post comments
Wed, 02/22/2012 - 17:49
#4
simmartin
simmartin's picture
This Cat's on a Hot Tin Roof

Online
Joined: 05/03/2011
Posts: 341

You can try to use a pulldown resistor at the analog pin to have a better ground reference... it could be floating for the simple reason that you are not using a input resistor on the analog pin...

Another tip could be to put a vTaskDelay(10); inside the while(1) loop...

Also you can leave the while(1) code blank, and see only inside the webserver if the analog value is floating or not

This Cat's on a Hot Tin Roof!

Top
  • Log in or register to post comments
Thu, 02/23/2012 - 16:08
#5
Creed
Offline
Joined: 09/15/2011
Posts: 13

Thanks for the reply. Got it working. With the while(1) loop blank, the analogue input was always a little jumpy. I tried using the pull down resistor and it had the effect of increasing the sensor range i.e. It may be programmed to activate the LED at 50 ~= (roughly) 3/4 of a foot. The larger the pull down resistor used the greater this distance became. Useful to know so I'm glad it came to my attention but it didn't solve the issue. Inserting the delay done the trick nicely. The code that worked is as follows:

 

#include "taskFlyport.h"

//int fin_command = 0;

void FlyportTask()
{
WFConnect(WF_DEFAULT);
while (WFStatus != CONNECTED);
UARTWrite(1,"Flyport connected... hello world!\r\n");

IOInit(d1out, out);
 

BYTE pwm1 = 1;          //pwm number 1
BYTE pwm5 = 3;   //pwm number 5


PWMInit(pwm1,50,2.75);  //..........................LEFT
  PWMInit(pwm5,50,10);  
 


int sensor_in;
 
while(1)
  {
 
   sensor_in = ADCVal(1);


    if( sensor_in < 50 )
    {
    IOPut(d4out, off);
    vTaskDelay(1);     
    

//......................... below sets the servo on


   PWMOn(d1out,pwm1);  //50hz 5% duty => 1 ms pulse over a 20ms timeperiod
   vTaskDelay(50);
   
   PWMOn(d1out,pwm5);  //50hz 10% duty => 2 ms pulse over a 20ms timeperiod
   vTaskDelay(50);
    }
    else{
    IOPut(d4out, on);
    vTaskDelay(1);
   

 

//............................. below turns the servo off
    PWMOff(pwm1);

    PWMOff(pwm5);
    }
}
}

 

The webserver display is still very jumpy e.g. If I stand stationary in front of the sensor its value will oscillate by a value between 30 - 50. The LED also blinks when the sensor has been activated. My use for the sensor is to activate a servo motor when an object comes within range and the brief delay doesn't affect its operation. This is all in aid of my final year project in electronics. When its all done I'll upload the report and a few videos I took throughout the year. it may be useful to someone as everything I'v done with the flyport is fairly basic but functional.

Thanks alot for your help. 

S Creed

Top
  • Log in or register to post comments
  • Technology
    • Overview
    • Downloads
    • Products
    • Universities
    • Projects
  • Business
    • Overview
    • System integrators
    • Distributors
    • Products
    • Projects
    • Services
  • Downloads
    • Downloads
    • Get Started
    • Projects
    • FAQ
  • Community
    • Join
    • Forum
    • Blog
    • Projects
    • Social
  • Buy
    • Store
    • Retailers
    • Distributors

openPICUS Newsletter

Copyright 2001 © OpenPICUS    -    All rights reserved    -    info@openpicus.com