Remote control by location (PIC in Oshonsoft)

Thread Starter

camerart

Joined Feb 25, 2013
3,836
hi C,
Looking at that TERM.txt, I agree with 'jjw' it looks wrong.?
Why are you printing the HB and LB bytes separately instead of a WORD value.?
E
Hi E,
I was happy to see the 2xBYTEs appear, but will look at WORD later.
In you CODE did you send 2xBYTEs or 1xWORD?
I was under the impression that the combining of the 2x BYTEs would be in the MASTER.
C
 

ericgibbs

Joined Jan 29, 2010
21,452
hi C,
The pulses per revolution is 360, which variant of the QEI method are you using.?
E
You can only send one 8 Bit Byte per SPI exchange, but a value of 359 requires 2 Bytes, so its sent as HB and then LB, the program OR's to the Bytes to make a 16Bit WORD.

eg: say brg=359 deci,
then
HB= 0x01 , LB = 0x67
So WORD = 0x0167 == 359 decimal
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,836
hi C,
The pulses per revolution is 360, which variant of the QEI method are you using.?
E
You can only send one 8 Bit Byte per SPI exchange, but a value of 359 requires 2 Bytes, so its sent as HB and then LB, the program OR's to the Bytes to make a 16Bit WORD.

eg: say brg=359 deci,
then
HB= 0x01 , LB = 0x67
So WORD = 0x0167 == 359 decimal
Hi E,
This all should be somewhere in my files, as we've done it all before.
I'm remembering POSCNT and MAXCNT. Things will dawn on me, I'll report back ;)
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,836
hi C,
The pulses per revolution is 360, which variant of the QEI method are you using.?
E
You can only send one 8 Bit Byte per SPI exchange, but a value of 359 requires 2 Bytes, so its sent as HB and then LB, the program OR's to the Bytes to make a 16Bit WORD.

eg: say brg=359 deci,
then
HB= 0x01 , LB = 0x67
So WORD = 0x0167 == 359 decimal
Hi E,
How does Oshonsoft do [ ORs ]?
C
 

ericgibbs

Joined Jan 29, 2010
21,452
hi,
Let brg be a 16 bit WORD
When brg = 0, thats 0000 0000, 0000 0000 ie 16 bit locations

Now say brg.HB = 0x01 thats 0000 0001
and
say brg.LB = 0x67 thats 0110 0111

So the compiler places
brg.HB in the 8 high bit locations of that WORD ie: 0000 0001 0000 0000
brg.LB in the 8 low bit locations of that WORD ie: 0000 0001 0110 0111

WORD is now 0x0167 == 359 decimal

You should really know how to construct a WORD by now.

E
 

ericgibbs

Joined Jan 29, 2010
21,452
hi jjw,
I used the WORD 'OR' so that 'C' might better understand what is happening with the HB and LB bytes.

I am surprised that he is having problems at this stage in building a WORD from HB LB Bytes.

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,836
hi jjw,
I used the WORD 'OR' so that 'C' might better understand what is happening with the HB and LB bytes.

I am surprised that he is having problems at this stage in building a WORD from HB LB Bytes.

E
Hi E,
I simply don't retain programming protocols.
If somethings not working as in this case, I look up old examples, then copy/paste, or ask in a forum.
I have many skills, that I'm natural at, I won't list them, but computing isn't one of them.
So either look up old examples, or ask in a forum, it's my only way. As long as someone's out there, I'll carry on.
Enjoy your computing expertise :)

So, the problem here:
I'm trying POSCNT tests, and I haven't yet figured out POSCNTL or POSCNTLB or POSCNTL = POSCNTL = POSCNTLB etc.
I tried [ poscnt = POSCNTH Or POSCNTL ] but as you have just explained, this didn't work.
I think I've got it now, let's see.
C
 
Last edited:

jjw

Joined Dec 24, 2013
823
hi jjw,
I used the WORD 'OR' so that 'C' might better understand what is happening with the HB and LB bytes.

I am surprised that he is having problems at this stage in building a WORD from HB LB Bytes.

E
This was discussed about 1.5 years ago in reading the bmp280.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,836

Thread Starter

camerart

Joined Feb 25, 2013
3,836
Hi,
Just found an interesting problem. The MASTER READings are 50% of the SLAVE WRITEings.
Here's a TXT: (I switch between the MASTER/SLAVE UARTS., so you see when I change)
I'll keep checking, and post the programs again, when I've sorted it out, or I'll ask.

C
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,836
Hi,
Following from #513, here is a TERM view plus an analysis image showing that the SLAVE output is the same as the SPI READings, which tells me that the corruption is in the MASTER.

Is it possible that timing is off, SHIFTING the MASTER input 1x BIT to the right?
C.
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,836
Hi,
I've programming the PICs to see where the '1/2ing error' started, and it appears to have been there since getting sensible results, see #497 TERM view. You can see [ 128 ] showing in the results, which is actually %00000000 shifted right 1xBIT, by in this case a [ 1 ], but it could be a [ 0 ] which makes it difficult to spot.
In the case above, TERM is showing the shift, but lately the TERM showing correct BYTEs, and the shift doesn't show till in the MASTER. It seems to me like to tight clock tolerances?

Could a pull down resistor on the MISO track help?

Does anyone know how this can happen?

EDIT: I'm getting a feint recollection of clock sampling 1/2 way along the CLK? Can someone remind me if they know what I mean please?
EDIT EDIT: Could it be something to do with SSPSTAT BIT7?
C.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,836
Hi,
I changed both SSPSTAT.SMP BITs to [ 1 ]
Here's the result: Turning the Incremental encoder 1xREV CW
Hopefully, I've stumbled on the answer to the [ 1/2ing ] problem, but can someone explain or verify what I've done please?
C
 

Attachments

ericgibbs

Joined Jan 29, 2010
21,452
hi C,
It is easier to follow if you print the WORD #QEIAZI
Showing it this way is a pain to follow the actual values... From SLAVE QEIAZILB= 2 QEIAZIHB= 84
Lets see the values as decimal values.
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,836
hi C,
It is easier to follow if you print the WORD #QEIAZI
Showing it this way is a pain to follow the actual values... From SLAVE QEIAZILB= 2 QEIAZIHB= 84
Lets see the values as decimal values.
E
Hi E,
I had to change round the LB and HB.
Here is the result:
Plus both programs.
C
 

Attachments

ericgibbs

Joined Jan 29, 2010
21,452
hi,
Is appears to be counting in 0.25deg increments.
If you made the QEIAZI a Single you could resolve to 0.25deg, if required.

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,836
hi,
Is appears to be counting in 0.25deg increments.
If you made the QEIAZI a Single you could resolve to 0.25deg, if required.

E
Hi E,
I used what I thought to be the best choice here: [ 110 = QEI enabled in 4x Update mode; position counter is reset on period match (POSCNT = MAXCNT) ] in SLAVE.

Once in MASTER how do I divide it down to DEGREES please?

When I changed the [ SMP ] BIT setting, what did I do?
Do you think this could have been the problem?
C
 
Top