Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:47 20 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : AS5600 Magnetic Rotary Encoder Module

Author Message
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 86
Posted: 10:12pm 10 Dec 2021
Copy link to clipboard 
Print this post

Hi MMBasic friends,

I recently bought an AS5600 rotary magnetic encoder.
Very pleased with it, easy to use (see my code)

As a man who's fitted an accelerometer to the catflap,
I'm always looking for like-minded souls.
( haha!.. think I've found a few in this shed !  )

Can we think of a good application for this module,
maybe a weathervane, or an inverted pendulum..



'---------------------------------------------
' AS5600 magnetic rotary encoder DPJ
' 3v3 4096 steps/360 deg
' agc ideally returning about 64
'---------------------------------------------

addr=&h36 'I2C address
Dim agc,rah,ral,ang As integer
'ie auto gain control, angle high byte,low byte,result angle
Pause 50 'power-up delay
I2C open 100,100,PU  'set up I2C..
'this is speed kHz,timeout ms, pullup

rdlp:

Pause 100
I2C write addr,0,1,&h1A 'select agc reg
I2C read addr,0,1,agc
I2C write addr,0,1,&h0C 'select raw ang reg
I2C read addr,0,1,rah
I2C read addr,0,1,ral
ang=(rah<<8)+ral
Print ang;"  ";agc;"  ";Chr$(13);

GoTo rdlp
Try swapping 2 and 3 over
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 10:56pm 10 Dec 2021
Copy link to clipboard 
Print this post

  DaveJacko said  Hi MMBasic friends...As a man who's fitted an accelerometer to the catflap


Hello and welcome... I am dying here          
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8298
Posted: 06:59am 11 Dec 2021
Copy link to clipboard 
Print this post

  Quote  As a man who's fitted an accelerometer to the catflap,
You just gotta love someone with such dedication!  
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 08:20am 11 Dec 2021
Copy link to clipboard 
Print this post

  DaveJacko said  Hi MMBasic friends,

I recently bought an AS5600 rotary magnetic encoder.
Very pleased with it, easy to use (see my code)

As a man who's fitted an accelerometer to the catflap,
I'm always looking for like-minded souls.
( haha!.. think I've found a few in this shed !  )

Can we think of a good application for this module,
maybe a weathervane, or an inverted pendulum..



'---------------------------------------------
' AS5600 magnetic rotary encoder DPJ
' 3v3 4096 steps/360 deg
' agc ideally returning about 64
'---------------------------------------------

addr=&h36 'I2C address
Dim agc,rah,ral,ang As integer
'ie auto gain control, angle high byte,low byte,result angle
Pause 50 'power-up delay
I2C open 100,100,PU  'set up I2C..
'this is speed kHz,timeout ms, pullup

rdlp:

Pause 100
I2C write addr,0,1,&h1A 'select agc reg
I2C read addr,0,1,agc
I2C write addr,0,1,&h0C 'select raw ang reg
I2C read addr,0,1,rah
I2C read addr,0,1,ral
ang=(rah<<8)+ral
Print ang;"  ";agc;"  ";Chr$(13);

GoTo rdlp



Neat device  

For multi-turn, the MCU would need to keep track though, right?
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025