Go to Post A good engineer will never stop learning. From his peers, technicians, and competitors. The field is just to vast for any one person to know it all. - Mr. Mike [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-02-2014, 16:59
DarthCoder DarthCoder is offline
Registered User
FRC #4309
 
Join Date: Aug 2012
Location: Washington
Posts: 37
DarthCoder is an unknown quantity at this point
PWM Input?

We need to be able to read a PWM input from a Radio Shack ultrasonic range finder. The PWM class only works for output, and we can't seem to get the counter class working either. Is there any way to read PWM from a digital input?
  #2   Spotlight this post!  
Unread 08-02-2014, 17:03
theawesome1730's Avatar
theawesome1730 theawesome1730 is offline
Registered User
FRC #1730 (Team Driven)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Lee's Summit, MO
Posts: 316
theawesome1730 will become famous soon enough
Re: PWM Input?

Not through digital since it is on/off and the range finder would output multiple values other than 0 and 1, but you can through the analog breakout on the cRIO
__________________



2015 GKC Engineering Inspiration
2015 Colorado Winners
  #3   Spotlight this post!  
Unread 08-02-2014, 17:05
DarthCoder DarthCoder is offline
Registered User
FRC #4309
 
Join Date: Aug 2012
Location: Washington
Posts: 37
DarthCoder is an unknown quantity at this point
Re: PWM Input?

This is the one we have http://blog.radioshack.com/2013/07/f...-range-sensor/

We're pretty sure it's PWM not analog.
  #4   Spotlight this post!  
Unread 08-02-2014, 17:35
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: PWM Input?

You are correct that it is a digital PWM input. However, it is also requires a digital output on the same pin to trigger a distance measurement. The cRIO FPGA wasn't designed to handle this use case. There are many other ultrasonic sensors that would be easier to use, including digital ones where the request and the response are on different pins. Alternately, you could build a circuit to separate the two signals.
  #5   Spotlight this post!  
Unread 08-02-2014, 17:57
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PWM Input?

Quote:
Originally Posted by DarthCoder View Post
Is there any way to read PWM from a digital input?
I wonder if you could read the pulse width by treating it like a counter.

Oops... Maybe not with that part number.


Last edited by Ether : 08-02-2014 at 18:01.
  #6   Spotlight this post!  
Unread 08-02-2014, 17:59
DarthCoder DarthCoder is offline
Registered User
FRC #4309
 
Join Date: Aug 2012
Location: Washington
Posts: 37
DarthCoder is an unknown quantity at this point
Re: PWM Input?

Tried that. It never returned anything but 0, and infinity. We even tested the counter with slower inputs and it worked that time. I think the sensor is too fast for the counter class.
  #7   Spotlight this post!  
Unread 08-02-2014, 18:27
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PWM Input?




The bottom of Page3 of the User's Guide for 2760342 implies that the SIG pin is a "Serial Monitor (9600)". Sounds like RS-232 to me, not PWM. Am I misinterpreting this?


  #8   Spotlight this post!  
Unread 08-02-2014, 18:33
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: PWM Input?

Quote:
Originally Posted by Ether View Post



The bottom of Page3 of the User's Guide for 2760342 implies that the SIG pin is a "Serial Monitor (9600)". Sounds like RS-232 to me, not PWM. Am I misinterpreting this?
I think that's talking about opening the serial monitor in the Arduino programming environment, so you that you can read the data that the Arduino code is sending over the serial port.

Here's the relevant portion of the arduino code for reading the sensor.

Code:
/*Begin the detection and get the pulse back signal*/
void Ultrasonic::DistanceMeasure(void)
{
    pinMode(_pin, OUTPUT);
	digitalWrite(_pin, LOW);
	delayMicroseconds(2);
	digitalWrite(_pin, HIGH);
	delayMicroseconds(5);
	digitalWrite(_pin,LOW);
	pinMode(_pin,INPUT);
	duration = pulseIn(_pin,HIGH);
}
  #9   Spotlight this post!  
Unread 08-02-2014, 18:47
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PWM Input?



Thanks Joe. I searched for a datasheet that documents the protocol of the SIG pin for this device but was not successful.

What I was looking for was this: Is the protocol strictly command/response, or can it be set up to continuously broadcast its distance measurements? And if so, is the pulse width user configurable into a range that the FPGA sampling rate could handle?



Last edited by Ether : 08-02-2014 at 18:57.
  #10   Spotlight this post!  
Unread 08-02-2014, 21:18
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 1,946
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: PWM Input?

Would not a counter count pulses rather than pulse width? It seems unless something is programed in the FPGA it is not doable.
  #11   Spotlight this post!  
Unread 08-02-2014, 22:38
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PWM Input?

Quote:
Originally Posted by FrankJ View Post
Would not a counter count pulses rather than pulse width? It seems unless something is programed in the FPGA it is not doable.
The getperiod() method in the counter class in WPILib uses FPGA to measure the pulse width using a microsecond timer.


Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:46.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi