Remote control by location (PIC in Oshonsoft)

trebla

Joined Jun 29, 2019
599
Microchip suggests this sequence for setting PORTA for digital inputs:
PORTA = 0 'clear PORTA
LATA = 0 'clear LATA
ANSEL = 0 'set all digital
TRISA = %11111111 'set PORTA all inputs

ANSEL bits 5-7 are for controlling PORTE analog functions
For PORTB use ANSELH instead
 

Thread Starter

camerart

Joined Feb 25, 2013
3,838
Microchip suggests this sequence for setting PORTA for digital inputs:
PORTA = 0 'clear PORTA
LATA = 0 'clear LATA
ANSEL = 0 'set all digital
TRISA = %11111111 'set PORTA all inputs

ANSEL bits 5-7 are for controlling PORTE analog functions
For PORTB use ANSELH instead
Hi T,
Here is the latest prgram, hope it's correct. RA0-2 still show voltages output.

J, #879 Updated with attachment

Drama! Sparks started coming from under the 5V REG, and a hole was burnt into the PCB. Possibly dried flux, turning to carbon. I added 2x capacitors and gave it a clean. Still warm, and the current showing is 100mA but wavering each side.
C.
 

Attachments

Last edited:

trebla

Joined Jun 29, 2019
599
Inputs without pull-up resistors are floating and high impedance measuring gives random results. In your schematics i see a connector attached to these inputs. I don't know are additional pull-ups needed or inputs are fixed externally through this connector. PIC18F46K20 has no internal pull-ups on PORTA.
 

jjw

Joined Dec 24, 2013
823
Hi T,
Here is the latest prgram, hope it's correct. RA0-2 still show voltages output.

J, #879 Updated with attachment

Drama! Sparks started coming from under the 5V REG, and a hole was burnt into the PCB. Possibly dried flux, turning to carbon. I added 2x capacitors and gave it a clean. Still warm, and the current showing is 100mA but wavering each side.
C.
The 5V reg warming is normal.
It consumes about (12V-5V)* 0.1A ~ 0.7W and should warm a few tens of degrees without heatsink.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,838
Hi J and T,
Didn't know that, could be dangerous! I left it on, as I am still in the process of making it, and it was an indicator of hot spots, but I didn't think it may have been the cause of hotspots?

The connector with the voltages, will be an analogue input, and no problem at the moment.

5Vreg warm, ok.

I've added the 4431 PIC, now both are flashing LEDs :)
I cut the tracks between the 2x PICs, until I'm certain they won't fight.
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,838
Hi,
Next to try SPI between the 2x PICs, I recall that the SLAVE needs to be fater than the MASTER. MASTER INT CLK 16mHz, SLAVE INT 8mHz, so the 4431 needs the HSPLL (OSCCON), which in turn needs a XTL, I'll add one.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,838
Hi,
I added an 8mHz crystal, and the setting for HSPLL, and the LED flashed for a while, then stopped.
I've gone back to 8mHz INT, but I remember a post saying that the SLAVE should be fatser than MASTER in SPI.
I've gone back to 8mHz INT, and will try with that, until it breaks.
C
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,838
Hi,
I'm still getting problems from flux tracking, even though I've cleaned the PCB with IPA, then PCB cleaner. This is why the LED stopped in #889.

Re-cleaner, and the tracks connected. Here is a logic analyser view:
EDITED.
C.
 

Attachments

Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,838
SPI looks somewhat odd or this is what you need?
Hi T,
So far it shows me that the PICs aren't getting hot (yet) and the SPI signals are showing.
When the SPI works properly, on the SPI image under 'protocols' it ususally shows SPI and a list.
I think the C/S should cover the whole exchange time, but as can be seen it only covers the beginning.

XTL stopping was an error, I meant LED, and even though I cleaned the PCB, under the LED connector, was flux. Now flashing again.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,838
Hi,
Here are the 2x programs:
Note the oscillator frequencies in the titles.
The SPI look better this time and is showing at bottom right.

There is a bit of a mix up, as firstly, the 46K20 MASTER send '1234' to the 4431 SLAVE and the SLAVE return ABCD, but as you can see in the SPI, attached, it's not correct.
C
 

trebla

Joined Jun 29, 2019
599
Seems to me like the master sends "4321" +CR +LF and before transmisson slave holds 'A' in SPI buffer. Sorry, i don't have experience with Oshonsoft, i have used years ago only PBP, mostly i use C or MPASM
 

Thread Starter

camerart

Joined Feb 25, 2013
3,838
Seems to me like the master sends "4321" +CR +LF and before transmisson slave holds 'A' in SPI buffer. Sorry, i don't have experience with Oshonsoft, i have used years ago only PBP, mostly i use C or MPASM
Hi T,
The Buffer swaps a MSG in MASTER (1234) with a message in SLAVE (ABCD) then send 1234 back on the next round. These are set messages, but 'live' it would have real messages.
I'm using programs, kindly written by members of this and other forums, which has slowly built up. I couldn't do it. I would have liked to write in 'C' but can't. So far these are Copy paste programs I hold from past programs. I will add peripherals, once I've got the 2x PICs happily 'talking'
C.
 

trebla

Joined Jun 29, 2019
599
I try figure out why slave sends dummy buffer content after each two bytes transmitted by master. It will take a while, maybe some other with more confident with Oshonsoft BASIC will answer faster.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,838
I try figure out why slave sends dummy buffer content after each two bytes transmitted by master. It will take a while, maybe some other with more confident with Oshonsoft BASIC will answer faster.
Hi T,
The programs, I'm copying, are previous working ones, so only check if it interests you, but I may find a better program, as I swap from PCB6 to PCB7.
Cheers, C
 

trebla

Joined Jun 29, 2019
599
Can you tell me the silicon revision number of the PIC18F46K20? Usually you see it in programmer window. Here is described how to find the number, at the document beginning, in second column.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,838
Can you tell me the silicon revision number of the PIC18F46K20? Usually you see it in programmer window. Here is described how to find the number, at the document beginning, in second column.
Hi T,
As I use Oshonsoft for programming, I don't have the MPLAB IDE, only IPE. If it's important, then I'll get it but it is quite a big program and for me, unecessary.
C
 
Top