Using incremental encoder to generate 0-359 Degrees Oshonsoft (NOTE: QEI SIM NOT SUPPORTED)

ericgibbs

Joined Jan 29, 2010
18,869
Your signal generator rings a bell and I think I made one. Although I hope you realise, that I don't want to generate signals, but use an incremental encoder attached to the QEI INPUT PINs to generate the quadrature.
hi C,
That signal generator is designed to connect to the 18F2431, QEI inputs and emulate a quadrature encoder, for bench testing of the 18F2431 program.
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
That signal generator is designed to connect to the 18F2431, QEI inputs and emulate a quadrature encoder, for bench testing of the 18F2431 program.
E
Hi E,
Ah good, I'll make one if the buttons aren't enough, thanks.

I just checked the incremental encoder that's in the post. It doesn't have an INDEX, only QEA and QEB outputs.
I also noticed that it's minimum voltage is 5V, so I'll have to remember to lower voltage to 3.3v before connecting.
C.
 

ericgibbs

Joined Jan 29, 2010
18,869
hi C,
The advantage of the Index pulse from an encoder, is the encoder generates the INDX pulse as the encoder shaft passes thru a fixed rotation point, used to reset the poscntr to 000.
Without an INDX you will have to use the CAPBUF, with a preloaded value. In our case that's 3559 decimal, for 0.1deg resolution.

I found the INDX useful on our double bearing unit, pre-set the encoder shaft rotation at the INDX for 'dead head' and 'level' .

This clip from the d/s is section for the QEx and INDX.

E
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
The advantage of the Index pulse from an encoder, is the encoder generates the INDX pulse as the encoder shaft passes thru a fixed rotation point, used to reset the poscntr to 000.
Without an INDX you will have to use the CAPBUF, with a preloaded value. In our case that's 3559 decimal, for 0.1deg resolution.

I found the INDX useful on our double bearing unit, pre-set the encoder shaft rotation at the INDX for 'dead head' and 'level' .

This clip from the d/s is section for the QEx and INDX.

E
Hi E,
Here is a TRACKER program using CAPBUF instead of INDEX:
It looks like there are 3x choices.
Either Use CAPBUF
Or add a microswitch to the encoder that's in the post.
Or buy an encoder with an INDEX, which are 2 to 10 x as much.
What do you suggest?
C
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,869
hi,
I would say a uSwitch will not be suitable, you are working 0.1deg resolution.
Buy a simple bubble level, the circular type, about3cms in diameter, ie: the level is a datum centre ring on the bubble hemisphere.

When setting up the Head and Tripod, place the level on top of the Head, adjust the tripod legs until the bubble indicates level for a 360 deg rotation of the Head.
You can then use either a Compass or known Trig points [church spires , chimneys etc] to align the Head. The Trig points can taken from Google Earth.

If using a Compass, point the Head due North [magnetic] and press a Set Zero button of you keypad. The button press should set the PIC's posxcnt to 000 on the Azimuth and Elevation.

Using a Trig point EN coordinates and knowing the Head EN coordinate of your Base point, enter the Azimuth angle using the keypad, press the enter button.
This should pre-load the Azimuth posxcnt with the keypad value and zero the Elevation posxcnt.

Do you follow OK.
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
I would say a uSwitch will not be suitable, you are working 0.1deg resolution.
Buy a simple bubble level, the circular type, about3cms in diameter, ie: the level is a datum centre ring on the bubble hemisphere.

When setting up the Head and Tripod, place the level on top of the Head, adjust the tripod legs until the bubble indicates level for a 360 deg rotation of the Head.
You can then use either a Compass or known Trig points [church spires , chimneys etc] to align the Head. The Trig points can taken from Google Earth.

If using a Compass, point the Head due North [magnetic] and press a Set Zero button of you keypad. The button press should set the PIC's posxcnt to 000 on the Azimuth and Elevation.

Using a Trig point EN coordinates and knowing the Head EN coordinate of your Base point, enter the Azimuth angle using the keypad, press the enter button.
This should pre-load the Azimuth posxcnt with the keypad value and zero the Elevation posxcnt.

Do you follow OK.
E
Hi E,
Yes I follow, but it isn't anything to do with a TRACKER, but the 'incremental encoder' will be fitted into an RC Transmitter, instead of the YAW control stick, #5. It will transmit 0 to 359 degrees, to the REMOTE, then the REMOTE will turn to that AZIMUTH. I can add a dial to the rotation knob, and press a button when it shows ZERO.
C.
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,869
hi C,
It is getting a little confusing in knowing which project or module you are working on.
There have been so many changes and additions in the last 5 years.

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
It is getting a little confusing in knowing which project or module you are working on.
There have been so many changes and additions in the last 5 years.

E
Hi E,
Yes, it's quite a big project really, with lots of elements to it.

The whole project is for radio control of a REMOTE, in my case at the moment a Tricopter which is a remote control 3x propellor helicopter. It is flown in a similar way to normal radio control, but I will be sending DIRECTION, ALTITUDE, LOCATION to the REMOTE. These then can be used in many ways, for example ZERO DIRECTION could mean the REMOTE will turn either NORTH or away from the TRANSMITTER.

What we are doing now is 1x Channel of the RC Transmitter, where a rotary encoder will take the place of the YAW stick of the transmitter.

For better signals in 'say' woodland, there is a TRACKER that will aim the antennas towards the REMOTE (I'll return to this later).

It is a concept which once finished will be open to experiment. I decided to make the project as I kept having to crash, if I ever couldn't tell which way round the REMOTE was aiming, for safety.

EDIT: Today I had to rewire the 18F4431 section, because the UART wasn't working, and I guessed it was the wires were to long, so I shortened them and now it's working:) It has a BUTTON for QEA and another for QEB, so I can STEP the QEI, as you suggested in #23 apart from the INDEX.

C.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
The 0 to 359 degrees is now a VARIABLE, and this is an SPI SLAVE.

I'm a bit puzzled whether this VARIABLE will always be in the same place, especially if I modify the program, so will the MASTER PIC be able to get this VARIABLE via SPI, or does it need to be converted to a REGISTER first?
C.
 

ericgibbs

Joined Jan 29, 2010
18,869
hi,
If the Variable is stored in the SPI Slave program, the Slave program knows that Variables Address.
When the Master requests the Variable from the Slave, the Slave will send the data to the Master.
The Master does not have to know where the Variable is stored in the Slave.
Is that the query.?
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
If the Variable is stored in the SPI Slave program, the Slave program knows that Variables Address.
When the Master requests the Variable from the Slave, the Slave will send the data to the Master.
The Master does not have to know where the Variable is stored in the Slave.
Is that the query.?
E
Hi E,
In this example: where the ?? are would I put the variable name, 'say' azi ?
C.
compss = 0 'CHIP SELECT COMPASS ON
SPISend 0x??
SPIReceive azi
compss = 1 'CHIP SELECT COMPASS OFF

NOTE: I need to add '1' to the first BIT e,g, 1???????? ????????
 

ericgibbs

Joined Jan 29, 2010
18,869
hi,
If you want to get data from Slave to Master , you send the Address of the Slave then the receive the Data.
The 'azi' is the address of the Slave device.
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
If you want to get data from Slave to Master , you send the Address of the Slave then the receive the Data.
The 'azi' is the address of the Slave device.
E
Hi E,
I'm puzzled regarding the SLAVE address.

This is an 18F4620 as MASTER and 18F4431 as SLAVE. What address is the 18F4431?
C.
 

jjw

Joined Dec 24, 2013
823
Hi E,
I'm puzzled regarding the SLAVE address.

This is an 18F4620 as MASTER and 18F4431 as SLAVE. What address is the 18F4431?
C.
I think Oshonsoft supports only SPI master.
You could use the HW SPI by using directly its registers.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi E and J,
Thanks.
You will notice on the Video, that his set up only worked when he disconnected the C/S wire. He says he doesn't know why and he'll work on it.
I think the C/S wire must be there as I have other slaves, which must be discriminated.

I's suggestion of using the SLAVE registers was in my question #30. I have a variable 'say' AZI. In the SLAVE, is it possible to put VARIABLE in a register/s then address it, as I do with the other SLAVE modules? I think I have the 18F4431 set up as SLAVE correctly, but I will keep checking.
C.
 
Top