Shop OBEX P1 Docs P2 Docs Learn Events
P2 Accessory Set - Control Board issue — Parallax Forums

P2 Accessory Set - Control Board issue

I think I found an issue using the Control Board from the P2X8C4M64P-ES Accessory Set on a Rev B P2 Eval Board. This little 4-button-widget doesn't pull its switched outputs to the supply rails:

- When a button is pressed, it firmly pulls the associated P2 pin to the 3.3V rail (good!)
- When a button is **released**, the input pin simply floats. (bad)

You can sometimes watch an unterminated output from this board wander. Sometimes if you keep reading an input for a few minutes and you'll see the boards output wander between a 0 and a 1. Bring your hand near it and it will sometimes change states. Touch it with a floating test lead and it makes a decent random number generator. :) This seems to violate the old mantra that "all pins MUST go somewhere (pick a rail) to prevent undefined operation".

Here is the FlexBASIC code I'm using to demo the oddity:
	direction(39,32) = input
	do
		print input(39,32)  ' 64006-ES(a) Control board is attached on pins 32-39
		pauseMS(500)
	loop

I'm going to mod my Control Board to include 10k pull-down resistors on each of the boards outputs, but certainly Parallax tested this. What am I missing?

Comments

  • cgraceycgracey Posts: 14,155
    edited 2020-02-01 20:08
    Wait! That is intentional. It's done that way so that you can enable pull-downs inside the pin and read back the state. I went through the same head-scratching as you when I first tried it out.

    Try this:
    CON	pinbase	= 32				'control board, +0..3 = LED outputs, +4..7 = PB inputs
    	pbmode	= %0000_000_111_010_00_00000_0	'PB pin mode, high = float, low = 15k-ohm
    
    DAT	org
    
    	wrpin	##pbmode,#pinbase+4 + 3<<6	'set PB pin mode for pins +4..7
    	drvl	#pinbase+4 + 3<<6		'output 15k-ohm lows on PB pins
    
    .loop	testp	#pinbase+4	wc		'copy PB[0] to LED[0]
    	drvc	#pinbase+1
    
    	testp	#pinbase+5	wc		'copy PB[1] to LED[1]
    	drvc	#pinbase+0
    
    	testp	#pinbase+6	wc		'copy PB[2] to LED[2]
    	drvc	#pinbase+2
    
    	testp	#pinbase+7	wc		'copy PB[3] to LED[3]
    	drvc	#pinbase+3
    
    	jmp	#.loop
    

    The order of the LEDs is different than the PB's.
  • Ha! So its not a bug... it's a feature! Cool.

    I mod'ed the board, but I did it in a way that lets me unmod it easily. I'm trying to use these Control Boards as part of an exercise for my Minions... and they're using BASIC with no idea how to in-line asm. So I'll make a BASIC function wrapper for your code and make it part of a library they can call. Easy-peasy.

    Thanks, Chip!!
Sign In or Register to comment.