IR Receive ... odd phenomenon
| Author |
Message |
LouisG Senior Member
 Joined: 19/03/2016 Location: AustraliaPosts: 130 |
| Posted: 03:45am 04 Jan 2023 |
|
|
|
Hi guys,
I'm a MicroMite veteran who is having his first crack at a PicoMite.
My project is to operate 24 relays from a PicoMite, singly or in combination, using an IR remote signal. Pins used will be GP0 to GP23 for the relays, GP24 for the IR receiver. Outputs will be into optocouplers with 1K series resistors.
I built breadboard versions of the IR Tx and Rx. The trial IR Tx works, successfully sending Device code = 1 and Key code = 2 on powerup.
The IR Receive breadboard follows the example in the PicoMite manual 5.07.05, page 30, and with the 9 lines of example code loaded it displayed the above two codes on the console accurately. However, when I added SETPIN code for setting up the 24 digital output pins the receiver stopped receiving the IR codes. See code below.
DIM INTEGER Relay(24)=(-1,1,2,4,5,6,7,9,10,11,12,14,15,16,17,19,20,21,22,24,25,26,27,29,31) FOR i = 1 to 24 : SETPIN (Relay(i)),DOUT : NEXT
DIM INTEGER DevCode, KeyCode SETPIN 32, IR IR DevCode, KeyCode, IRInt
DO PAUSE 1000 LOOP
SUB IRInt PRINT "Received device = " DevCode " Key = " KeyCode END SUB
If I delete or comment out the FOR...NEXT statement in Line 2, the IR code is accurately received, as displayed on the console.
If I leave the FOR...NEXT in, the IR code is not received (although the 24 outputs are properly set to DOUT).
I need both! What am I doing wrong? Any help would be appreciated.
Louis |
|
palcal
 Guru
 Joined: 12/10/2011 Location: AustraliaPosts: 2039 |
| Posted: 03:53am 04 Jan 2023 |
|
|
|
Should it be SETPIN Relay(i),DOUT |
|
LouisG Senior Member
 Joined: 19/03/2016 Location: AustraliaPosts: 130 |
| Posted: 04:25am 04 Jan 2023 |
|
|
|
Thanks Palcal.
I think Setpin is working OK. Not getting any error messages, The Outputs are correctly set as DOUT. I checked them from the command line.
- |
|
TassyJim
 Guru
 Joined: 07/08/2011 Location: AustraliaPosts: 6546 |
| Posted: 04:36am 04 Jan 2023 |
|
|
|
As a test, don't set PIN 31 as an output. There might be some interaction between 31 and 32 as both are analog pins.
You could take it further with all the pins and see if it is only one or a few pins that causes the problem.
I assume you have tested your wiring to make sure there isn't a bridge between 31 and 32?
Jim |
|
LouisG Senior Member
 Joined: 19/03/2016 Location: AustraliaPosts: 130 |
| Posted: 04:58am 04 Jan 2023 |
|
|
|
I checked, Jim.
No bridge between 31 and 32. I removed pin 31 from Setpin array. Still the same phenomenon.
- |
|
phil99
 Guru
 Joined: 11/02/2018 Location: AustraliaPosts: 3321 |
| Posted: 04:59am 04 Jan 2023 |
|
|
|
An experiment. What happens if you setup the IR & PAUSE 100 before the DOUTs? Does it stop working? Does a PAUSE 1 in the For / Next loop help? |
|
LouisG Senior Member
 Joined: 19/03/2016 Location: AustraliaPosts: 130 |
| Posted: 05:10am 04 Jan 2023 |
|
|
|
Will try, Phil99
However, Jim's suggestion jolted my memory of a week ago. When I set only 4 relays (1 to 4) using Setpin, the IR code was received OK. With the full 24 outputs set it was not received. I just tried it with 4. It worked properly. It's a place to start looking.
Will investigate yours too, Phil99. Thanks. |
|
Turbo46
 Guru
 Joined: 24/12/2017 Location: AustraliaPosts: 1694 |
| Posted: 05:23am 04 Jan 2023 |
|
|
|
Do you have any OPTIONs set that may interfere with setting any pins?
OPTION LIST
Bill |
|
LouisG Senior Member
 Joined: 19/03/2016 Location: AustraliaPosts: 130 |
| Posted: 06:15am 04 Jan 2023 |
|
|
|
No. Option List is empty.
Some more info. I think I've narrowed it down.
Apply Setpin DOUT only for relay outputs 1-4, IR code received OK Apply Setpin DOUT only for relay outputs 1-5, IR code NOT received. Apply Setpin DOUT only for relay outputs 6-24, IR code received OK
So Relay 5 output is the culprit.
Another observation: Output 5 outputs 3.3V on powerup. However, when made a DOUT on its own, the 3.3V disappears and the pin behaves normally when set to logic 1 or 0. This could be a defect. I have another Pico with the same Output 5 (GP3) doing the same thing.
Will try to reorganise pin allocations to get it working or get a new Pico.
Thanks everyone for nudging me towards a solution. |
|
TassyJim
 Guru
 Joined: 07/08/2011 Location: AustraliaPosts: 6546 |
| Posted: 06:23am 04 Jan 2023 |
|
|
|
Good to see you making progress. It would be interesting to see if you can use pin 5 as the IR receive and pin 32 as an output.
Jim |
|
phil99
 Guru
 Joined: 11/02/2018 Location: AustraliaPosts: 3321 |
| Posted: 07:15am 04 Jan 2023 |
|
|
|
Tested 2 Picos freshly flashed with the latest 5.07.06RC1. GP0 to GP5 all just a few mV.
Could the 3V3 be leakage on the breadboard? Measure that position with the Pico removed. Or try with the Pico in a different place on the breadboard. |
|
Volhout Guru
 Joined: 05/03/2018 Location: NetherlandsPosts: 5994 |
| Posted: 07:36am 04 Jan 2023 |
|
|
|
Hi LouisG,
Noticed you have a "dummy entry" in your array:
DIM INTEGER Relay(24)=(-1,
Picomite has a nice way to avoid this:
OPTION BASE 1
When using this option the lowest index into the array changes from the default "0" to "1".
Regards,
Volhout |
|
matherp Guru
 Joined: 11/12/2012 Location: United KingdomPosts: 11635 |
| Posted: 08:17am 04 Jan 2023 |
|
|
|
Unplug the Pico from the breadboard and just wire the IR receiver with flying wires then test. As Phil says there should be no voltage on pins as powered up |
|
LouisG Senior Member
 Joined: 19/03/2016 Location: AustraliaPosts: 130 |
| Posted: 10:35am 04 Jan 2023 |
|
|
|
Matherp and Phil proved to be spot on. I removed the Pico and was astonished to measure a bridge from Pin 6 to Pin 35 on the Vero proto board. All fixed now. Thanks Guys.
- |
|