Parallax Forums
  HomeLog InRegisterCommunity CalendarSearch the ForumHelp
   
Parallax Forums > Public Forums > Stamps In Class > Better Boe-Bot IR Distance Measurements (Circuit + Programs)  Forum Quick Jump
 
New Topic Post Reply Printable Version
27 posts in this thread.
Viewing Page :
 1  2 
[ << Previous Thread | Next Thread >> ] | Show Newest Post First ]

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 12/7/2005 12:57 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
This circuit below and the attached programs provide distance measurements that are better than the examples in Robotics with the Boe-Bot, Chapter 8.  The measurements split a one foot (approx) distance into eight zones that are pretty evenly spaced, and there's next to no jitter in the measurements. 
 
    
 
The example programs make the distance measurement by placing different resistances in series with the IR LEDs.  The different series resistances are set by manipulating the input/output states of P4, P5, and P6.  In the initialization of the program, P4 to P7 are all set LOW (connected to Vss), but left as inputs with the command OUTB = %0000.  After that, the program manipulates which of those pins are connected to VSS and which of them are inputs with by setting DIRB equal to different values.  For example, DIRB = %0101 sets P6 and P4 to outputs, but leaves P5 an input.  Since earlier in the program, the OUTB was set to %0000, any I/O pin that gets changed to an output will send the LOW signal.  If DIRB = %0001, that makes P6 and P5 inputs, but P4 is output-low.  That means P4 is connected to Vss.  Whenever anything is connected to Vss, it is commonly referred to as connected to ground, or "grounded". 
 
The example programs use FOR DIRB = 1 to 7...NEXT to take P4, P5, and P6 through the following input/output combinations: %0001, %0010, %0011, %0100, %0101, %0110, %0111.  Each different OUTB setting causes different combinations of parallel resistors to be in series with the IR LEDs.  The thing about different parallel combinations of resistors is that they provide different levels of series resistance with the IR LEDs.  From Robotics with the Boe-Bot, Chapter 7, Activity #3, we know that different series resistances equate to different IR LED headlight brightnesses.  The brighter the IR LED, the further the IR receiver can see to detect an object.  Inside the FOR...NEXT loop, the code counts the number of detections each side saw, and equates that to a distance.
 
Here is the equation for calculating the equivalent resistance of one or more parallel resistors:
 
  Req = (R1-1 + R2-1 + R3-1 + ... + RN-1)-1
 
Here is another form of the same equation:
 
  Req = 1 / (1/R1 + 1/R2 + 1/R3 + ... + 1/RN)
 
Let's say DIRB = %0111.  That means that all three resistors are connected to Vss and are part of the circuit.  To calculate the equivalent resistance in series with the IR LED, it's:
 
  Req = 1 / (1/2000 + 1/4700 + 1/10000) = 1230 ohms
 
Here's another example with DIRB = %0101.  With this, configuration, P6 and P4 are grounded, but P5 is an input.  So the 4.7 k resistor is not part of the circuit, and we only want to calculate the parallel resistance for the 10 k and 2 k resistors.  The notation for parallel resistance is R1 || R2, etc.  So, this calculation is for 2 k || 10 k:
 
  Req = 1 / (1/2000 + 1/10000) = 1667 ohms.
 
The different series resistances you can get from the seven different combinations of OUTB are: 1230, 1402, 1667, 2000, 3197, 4700, and 10,000.
 
Both programs below are also attached to this post.
 
This example program tests the distance for both IR Detectors and displays it in the Debug Terminal.  You should be able to get values from 0 to 7, wich corresponds to between 1 inch and 1 foot. 
 
' -----[ Title ]--------------------------------------------------------------
' TestDistnaceWithNewCircuit.bs2
' Test sensitivity of new IR distance circuit.
 
' {$STAMP BS2}                               ' Stamp directive.
' {$PBASIC 2.5}                              ' PBASIC directive.
 
' -----[ Variables ]----------------------------------------------------------
irDetectLeft   VAR     Bit
irDetectRight  VAR     Bit
distanceLeft   VAR     Nib
distanceRight  VAR     Nib
 
' -----[ Initialization ]-----------------------------------------------------
DEBUG CLS, "Left   Right", CR
OUTB = %0000
 
' -----[ Main Routine ]-------------------------------------------------------
DO
 
  GOSUB Get_Ir_Distances
  DEBUG "  ", DEC1 distanceLeft, "     ", DEC1 distanceRight, CRSRX, 0
  PAUSE 100
 
LOOP
 
' -----[ Subroutine - Get IR Distances ]--------------------------------------
 
Get_Ir_Distances:
 
  distanceLeft = 0
  distanceRight = 0
 
  FOR DIRB = 1 TO 7
 
    FREQOUT 7,1,38500
    irDetectLeft = IN8
    distanceLeft = distanceLeft + irDetectLeft
    FREQOUT 3,1,38500
    irDetectRight = IN2
    distanceRight = distanceRight + irDetectRight
 
  NEXT
 
  RETURN
 
This example program is the following Boe-Bot program from Robotics with the Boe-Bot, Chapter 8, Activity #2.  With this program, the Boe-Bot should be able to lock onto and follow an object with much less jitter.
 
' -----[ Title ]--------------------------------------------------------------
' FollowingBoeBotWithNewDistanceCircuit.bs2
' Boe-Bot adjusts its position to keep objects it detects in zone 4.
 
' {$STAMP BS2}                               ' Stamp directive.
' {$PBASIC 2.5}                              ' PBASIC directive.
 
DEBUG "Program Running!"
 
' -----[ Constants ]----------------------------------------------------------
Kpl            CON     -15
Kpr            CON     15
SetPoint       CON     4
CenterPulse    CON     750
 
' -----[ Variables ]----------------------------------------------------------
irDetectLeft   VAR     Bit
irDetectRight  VAR     Bit
distanceLeft   VAR     Nib
distanceRight  VAR     Nib
pulseLeft      VAR     Word
pulseRight     VAR     Word
 
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 4, 2000, 3000
 
' -----[ Main Routine ]-------------------------------------------------------
DO
 
  GOSUB Get_Ir_Distances
 
  ' Calculate proportional output.
  pulseLeft =  SetPoint - distanceLeft  * Kpl + CenterPulse
  pulseRight = SetPoint - distanceRight * Kpr + CenterPulse
 
  GOSUB Send_Pulse
 
LOOP
 
' -----[ Subroutine - Get IR Distances ]--------------------------------------
Get_Ir_Distances:
 
  distanceLeft = 0
  distanceRight = 0
 
  FOR DIRB = 1 TO 7
 
    FREQOUT 7,1,38500
    irDetectLeft = IN8
    distanceLeft = distanceLeft + irDetectLeft
 
    FREQOUT 3,1,38500
    irDetectRight = IN2
    distanceRight = distanceRight + irDetectRight
 
  NEXT
 
  RETURN
 
' -----[ Subroutine - Get Pulse ]---------------------------------------------
Send_Pulse:

  PULSOUT 13,pulseLeft
  PULSOUT 12,pulseRight
  PAUSE 5
  RETURN

Post Edited (Andy Lindsay (Parallax)) : 12/7/2005 10:03:24 PM GMT


Image Attachment :
Image Preview
NewBoeBotDistanceCircuit.jpg
  50KB (image/pjpeg)
This image has been viewed 6769 time(s).

File Attachment :
TestDistances.bs2   1KB (application/octet-stream)
This file has been downloaded 675 time(s).

File Attachment :
FollowingBoeBotWithNewDistanceCircuit.bs2   2KB (application/octet-stream)
This file has been downloaded 649 time(s).
Back to Top
 

Steve Joblin
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2004
Total Posts : 794
 
   Posted 12/7/2005 4:51 PM (GMT -8)    Quote This PostAlert An Admin About This Post.

Very cool approach!  I am going to implement it using a DS1804 Solid State Pot (got that idea from Matt Gilliland's Cookbook series!).  I was going to suggest that this is a perfect candidate for you to add to the "Mini Projects" list, but see you already added.  Very much appreciated!!!!

Steve

Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 12/7/2005 5:17 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Thanks Steve.

Yes, the digital pot is a great way to further increase the distance resolution. For this particular project, I tried to stick with parts that already come in the Robotics with the Boe-Bot kit. However, those who have both What's a Microcontroller and Robotics with the Boe-Bot kits can use the AD5220 10 k Digital Potentiometer from the What's a Microcontroller kit. Parallax also sells the AD5220 individually for $3.25. Here's the product page link: <http://www.parallax.com/detail.asp?product_id=604-00010>.

There are three different possible end to end resistances in the DS1804. I would recommend using the 10 k version; it will give you the best resolution.

I haven't actually posted anything on that yet, and it'll be a while before I get to it. Perhaps you'll have something up before then. Let us know how it goes.

Regards, Andy

Post Edited (Andy Lindsay (Parallax)) : 12/8/2005 1:26:49 AM GMT

Back to Top
 

kiros
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Nov 2005
Total Posts : 2
 
   Posted 12/22/2005 4:48 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
I liked this much better then the 1 that came with the manual :D
Thx for this. I will try to add more to the kode, if i find out how everything works.
I've never realy koded much before :P But if i make it, i will post the results.
Again, thx for this 300% better solution.

Kim, Norway
Back to Top
 

Dave45
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2006
Total Posts : 36
 
   Posted 1/21/2006 7:26 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
I think I understand the schematic, but I'm not positive about it. Would it be possible to improve on it some. I'm learning but I'm new at this and don't want to make a mistake. Thanks.
Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 1/22/2006 7:00 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Here is a wiring diagram that I "think" is correct.  It would be a good idea to review Chapter 2, Activity #2 and Appendix C in Robotics with the Boe-Bot before building the circuit.

For getting used to building circuits from schematics (without the aid of a wiring diagram), start with Appendix D: Breadboarding Rules.  Then, pick a new circuit from the book each day and try drawing the schematic from the wiring diagram, then look at the schematic in the book and reconcile the differences.  For this, it will be important to use the PDF version since it's in color (for resistor color code identification). 

After working on that for a while, try building circuits from the schematics.  To be on the safe side, draw the schematic from the circuit you have build, and reconcile the two before connecting power.

Diagram updated 1/23/06, 8:20 PM PST:

 

Post Edited (Andy Lindsay (Parallax)) : 1/24/2006 4:21:42 AM GMT


Image Attachment :
Image Preview
NewBoeBotDistanceCircuitB.jpg
  159KB (image/pjpeg)
This image has been viewed 6531 time(s).
Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 1/23/2006 8:17 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Dave,

There was an error in the wiring diagram I uploaded yesterday. The right IR detector's output was connected to P0 (with a 220 ohm resistor). According to the schematic, it should have been connected to P2. Also, the IR LED leads labeled "Anodes" should have been labeled "Cathodes". 
 
The wiring diagram in the previous post has been updated to reflect these changes.

Regards, Andy

Post Edited (Andy Lindsay (Parallax)) : 1/24/2006 4:23:49 AM GMT

Back to Top
 

Ryan Clarke
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 745
 
   Posted 1/23/2006 8:53 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Andy,

As soon as I have a free moment I'll hook this up with a digital pot-

Ryan


Ryan Clarke
Parallax Tech Support

RClarke@Parallax.com

Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 1/23/2006 9:07 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Excellent. I just donated a 10 k AD5220 Digital Potentiometer from the What's a Microcontroller Parts Kit to the cause. It'll be on your desk.


Post Edited (Andy Lindsay (Parallax)) : 1/24/2006 5:10:58 AM GMT

Back to Top
 

Zoot
[ robots ]



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Apr 2006
Total Posts : 1596
 
   Posted 9/4/2006 8:30 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Thank you Mr. Lindsay -- this is a great way to get better IR. I did a version of this with just two pins and two resistors, to make a very accurate HI/LO range IR.

I made a little web page calculator that lets you plug in resistor values and get the total resistance for selected "on" resistors. Not sure if anyone will find this helpful, but here it is:

1uffakind.com/robots/resistorLadder.php

Please feel free to double check my math functions for possible errors! Parallax rocks!


When the going gets weird, the weird turn pro. -- HST

Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 9/5/2006 8:18 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Hey, Zoot,

That looks great! It's a perfect link for this thread too.

Regards, Andy
Back to Top
 

Evil Axis
Blue Ninja Rider

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Oct 2006
Total Posts : 9
 
   Posted 11/4/2006 7:49 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Thanks for this. After doing the follower program, I searched the forums for a way to reduce the jitter and found this.

There is a small error in FollowingBoeBotWithNewDistanceCircuit.bs2

this code:
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 4, 2000, 3000


should be:
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 1, 2000, 3000


since the wiring diagram shows the piezo speaker connected to pin1, and the piezo speaker cannot use pin4, since it is connected to a resistor.

The program definitely does reduce jitter quite a bit, but the bot still jitters a fair bit. So I was wondering if there was a way to get it to sit still when it is in the right spot, or is instability in the measured values normal for the IR sensors?
Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 11/5/2006 4:35 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Thanks for posting the correction. There are a number of different ways to calm down the jitter.

The first is by simply averaging a number of measurements. Try taking four or five measurements (and delivering four or five pulses). Keep adding up the measurements, then divide by the number of measurements you took. After that, recalculate the proportional drive that gets applied as you take the next four or five measurements (and deliver the next four or five pulses).

Another approach that can clean up the motion is with PID control. This one will take a little more work. Here is a link to a tutorial on the PID algorithm:

PID Control Intro with the BASIC Stamp <http://forums.parallax.com/forums/default.aspx?f=6&m=66982>

Another option would be to use a better distance sensor. For example, Ping)))Dar could be modified for following: <http://forums.parallax.com/forums/default.aspx?f=6&m=129099>


Andy Lindsay
Education Department
Parallax, Inc.

Back to Top
 

Evil Axis
Blue Ninja Rider

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Oct 2006
Total Posts : 9
 
   Posted 11/6/2006 5:26 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
I read your post above, and it makes me think a rolling average would work nicely.

For example

I would need the following:
a counter > cntr
number of measurements to average by > avgNum (let's say 4 for this example)
an array to keep the measurements in

then while cntr < avgNum I start filling the array, and average by cntr to decide what to do

once cntr = avgNum, then I start pushing new measurements into the array, and moving old measurements out of the array,
this would provide me with a rolling average.

This is my idea.

I am also thinking I could just start filling the array and average by avgNum from the begging, and accept a few milliseconds of weirdness while the program goes through the first cycles.

Anyhow, I have to go to work now, and don't have time to code this. If I get it done tonight, then I will post the code here.

Thanks!
Back to Top
 

Evil Axis
Blue Ninja Rider

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Oct 2006
Total Posts : 9
 
   Posted 11/6/2006 5:30 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
I added the averaging into the program, and it really does slow down the jitter, but it doesn't go away. I found that averaging over 4 pulses works ok. When the target does not move, then the bot rocks back and forth like a crazy person, but much slower than the original jitter

here is the code:


' added constant
AvgBy          CON     4

'added VARs
distLeftArray  VAR     Nib(AvgBy)
distRightArray VAR     Nib(AvgBy)
index          VAR     Nib
avgDistLeft    VAR     Byte
avgDistRight   VAR     Byte

'in the initialization, I fill the array with the target value, so the bot doesn't move until it has a good average
FOR index = 0 TO AvgBy - 1
  distLeftArray(index) = SetPoint
  distRightArray(index) = SetPoint
NEXT

'this is the new main routine
DO

  GOSUB Get_Ir_Distances
  'shuffle older values to higher index in the array
  FOR index = AvgBy - 2 TO 0
    distLeftArray(index + 1) = distLeftArray(index)
    distRightArray(index + 1) = distRightArray(index)
  NEXT
  distLeftArray(0) = distanceLeft
  distRightArray(0) = distanceRight

  'calculate rolling average
  avgDistLeft = 0
  avgDistRight = 0
  FOR index = 0 TO AvgBy - 1
    avgDistLeft = avgDistLeft + distLeftArray(index)
    avgDistRight = avgDistRight + distRightArray(index)
  NEXT
  avgDistLeft = avgDistLeft / AvgBy
  avgDistRight = avgDistRight / AvgBy
  ' Calculate proportional output.

  pulseLeft =  SetPoint - avgDistLeft  * Kpl + CenterPulse
  pulseRight = SetPoint - avgDistRight * Kpr + CenterPulse

  GOSUB Send_Pulse

LOOP


Anyhow, i hope someone finds this interesting or useful
You only have to change the value of AvgBy to experiment with different averages. 4 works pretty well, with 10 it just sits there, 5 and 6 work, but are slower to respond.

Andy,

thanks for the awesome posts. I have read some of your other ones, and the instructions and diagrams are spectacular. You should work for parallax! ;-)

Post Edited (Evil Axis) : 11/7/2006 1:35:00 AM GMT

Back to Top
 

Evil Axis
Blue Ninja Rider

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Oct 2006
Total Posts : 9
 
   Posted 11/6/2006 6:10 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
After doing the averaging, I carefully read your post about PID control. I haven't tried to integrate the PID algorithms into the program, but it seems that i will never get the bot to sit still when the object it is following stops, since the measurements from the IR pairs are so inaccurate.

Am I correct in that assumption?

On the other hand, the PID stuff is really interesting.

Sorry if I hijacked the thread. I just got really interested in making the jitter go away. Seems that I am banging into the limits of the sensors though.
Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 11/7/2006 9:49 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Well, attached is a video clip that contrasts P vs. PID with the same noisy sensors.  The first bot is the same old P control example with the Boe-Bot's motion mirroring the noise it's getting from its distance sensors.  The second bot is a PID controlled bot.  Same noisy sensors, much better tracking (both dynamic and static). 
 
There's an apple and orange aspect here since the PID bot has a Propeller chip instead of a BASIC Stamp.  However, the Propeller's ability to get 40 distances instead of just 5 from the same sensors only served to make its jitter worse.  With only proportional control, the Bot with the Propeller chip jittered so badly in response to all the distance sensor noise that it would lose sight of the the object it was tracking and wonder off.  So the PID really did a great job of cleaning up its object following behavior. 
 
Although I've never gotten around to writing PID Boe-Bot following code, I'm very confident that it's doable.  With some tuning of the Kp, Ki, and Kd, PID should clean up the Boe-Bot's behavior just as well as the performance on the video clip.  You may even be able to clean it up further by using your current averaging code as an input filter before the PID calculations. 
 
Yeah, you're right, we are drifting a little off the topic of this thread.  Well, if you start developing code and have questions or code to post, definitely start a new thread.


Andy Lindsay
Education Department
Parallax, Inc.

Post Edited (Andy Lindsay (Parallax)) : 11/7/2006 5:53:47 PM GMT



File Attachment :
P vs PID control.zip   1.88Mb (application/x-zip-compressed)
This file has been downloaded 468 time(s).
Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 11/7/2006 10:07 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
One other thought. To make the Boe-Bot stay still when the object is not moving, you could add some code that works from the sum instead of the average. An IF...THEN statement can decide whether or not that sum has changed enough to make it worth running the servos.
 
 


Andy Lindsay
Education Department
Parallax, Inc.

Post Edited (Andy Lindsay (Parallax)) : 11/7/2006 6:16:47 PM GMT

Back to Top
 

SSteve
Baritone



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Mar 2006
Total Posts : 549
 
   Posted 6/26/2007 10:29 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Andy Lindsay (Parallax) said...
There's an apple and orange aspect here since the PID bot has a Propeller chip instead of a BASIC Stamp.

Hey, Andy, do you still have that Propeller code laying around? I'd love to try this with my Spin Stamp.


OS-X: because making Unix user-friendly was easier than debugging Windows

links:
My band's website
Our album on the iTunes Music Store

Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 6/26/2007 2:21 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Yes, it's in the PEKbot thread in the Applications section of the Propeller Education Kit Labs thread:

http://forums.parallax.com/forums/default.aspx?f=25&m=156644


Andy Lindsay
Education Department
Parallax, Inc.

Back to Top
 

MichelB
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Mar 2009
Total Posts : 154
 
   Posted 7/4/2009 8:23 AM (GMT -8)    Quote This PostAlert An Admin About This Post.

It's written in the comments "The different series resistances are set by manipulating the input/output states of P4, P5, and P6. In the initialization of the program, P4 to P7 are all set LOW (connected to Vss), but left as inputs with the command OUTB = %0000". If this command is in TestDistances.bs2 I don't see it in FollowingBoeBotWithNewDistanceCircuit.bs2. Is it a forgetting? Best regards.

 P.S.: Dear Andy, can you give us the code (.bs2) to add to make the Boe-Bot stay still when the object is not moving?

 


Post Edited (MichelB) : 7/6/2009 11:23:26 AM GMT

Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 7/6/2009 11:22 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Hi MichelB,
 
OUTB = %0000 ensures that all the any I/O pin in bank b (P4..P7) will send a low signal if its corresponding direction register bit is set to output with a binary 1. 
 
For example, OUTB = %0000 and DIRB = %0101 sets P4 and P6 output-low while leaving P5 and P7 as inputs.  If you change DIRB to %0010, all I/O pins will be input except for P5, which will be output-low. 
 
When an I/O pin is set to input, it's about like unplugging the resistor from the socket.  So, with DIRB = %0101, the signal can pass to ground (output-low = shorted to ground) through the resistors connected to P4 and P6, but not P5.  When DIRB is %0010, the signal can pass through the resistor connected to P5, but not the other resistors.
 
Andy


Andy Lindsay
Education Department
Parallax, Inc.

Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 7/6/2009 12:32 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
 
MichelB said...
P.S.: Dear Andy, can you give us the code (.bs2) to add to make the Boe-Bot stay still when the object is not moving?
 
Code is attached.  It combines a running history of the last four distances with a little bit of deadband.  Please try it out and let me know if it performs as well as the one in our office.  (Comparison video clips coming soon.)


Andy Lindsay
Education Department
Parallax, Inc.



File Attachment :
NewDistanceFollowingWithAveragesAndDeadband.bs2   2KB (application/octet-stream)
This file has been downloaded 161 time(s).
Back to Top
 

MichelB
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Mar 2009
Total Posts : 154
 
   Posted 7/7/2009 12:15 AM (GMT -8)    Quote This PostAlert An Admin About This Post.

Thank you Andy for attached code. My first question was what it follows:

In the attached program "TestDistanceWithNewCircuit.bs2" we can find in Initialization: OUTB = %0000 and in Subroutine: FOR DIRB = 1 TO 7, but in the attached program "FollowingBoeBotWithNewDistanceCircuit.bs2" OUTB = %0000 disappeared even in your last attachement. Is it a forgetting or it is not necessary to initialize with OUTB = %0000?

Best regards 


Post Edited (MichelB) : 7/7/2009 4:30:49 PM GMT

Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1103
 
   Posted 7/7/2009 9:15 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
MichelB,

Thanks for examining the code and asking. We appreciate these questions because this material will probably get revised and republished soon. At that time, I will add an information box that clarifies this point.

You are correct, it is not necessary to initialize with OUTB = %0000 because the BASIC Stamp initializes all its variables to zero. I added it to the first program example for the sake of discussion, but neglected to mention that an OUTB = %0000 initialization is redundant.

Andy


Andy Lindsay
Education Department
Parallax, Inc.

Back to Top
 
[ << Previous Thread | Next Thread >> ]
New Topic Post Reply Printable Version
27 posts in this thread.
Viewing Page :
 1  2 
 
Forum Information
Currently it is Tuesday, February 09, 2010 3:17 AM (GMT -8)
There are a total of 415,988 posts in 57,637 threads.
In the last 3 days there were 78 new threads and 885 reply posts. View Active Threads
Who's Online
This forum has 18517 registered members. Please welcome our newest member, try388.
50 Guest(s), 7 Registered Member(s) are currently online.  Details
Graham Stabler, humanoido, Bob Lawrence (VE1RLL), computer guy, Rick Brooks, JohnandElspeth, mikestefoy