Thanks David.

Indeed that is your code as I had mentioned, it's really helping me picking 
up pic assembly for this purpose. And the chip I'm working on is 
PIC16LF1519 as you use it in your NWLD5 
(http://www.cathodecorner.com/nwl/NWLD5schem.pdf). 

What I had found confusing was that the battery voltage input is on AN5 and 
so I thought you'd select channel 5, instead it only works on channel 4. I 
can see now it's probably because there is no ADC on bit 4 of ANSELA. I had 
connected Z of the ADXL to AN4 (pin21) and I couldn't record an ADC 
conversion. I can see now why! Oops..

movlw   B'01110010'     ; internal RC oscillator, AN3 Vref
movwf   ADCON1
movlw   B'00111011'     ; AN0, AN1, AN3, AN4, AN5 are analog
movwf   ANSELA

You are right, you don't need X-Y-Z for the motion detection and it would 
use more power for no reason but I wanted to try and set the time using the 
accelerometer instead of the buttons. It may not be a good idea, it will 
still be a good learning exercise for me. 

Best regards,
Max
Il giorno sabato 10 ottobre 2020 alle 06:54:57 UTC+1 nixiebunny ha scritto:

> Max,
>
> Hi. I wrote all that code.
>
> The NWR watch that I designed uses all the capabilities of the
> PIC16LF722 chip. It was carefully engineered to do exactly what it
> needs to do and nothing more. Every pin does useful work, some of them
> doing two or three jobs at once. It has absolutely zero room for extra
> features.
>
> If you need to read all three axes of the accelerometer (I don't know
> why you would), then you need to use a PIC chip that has more pins. I
> used such a chip to make the NWL watch. It uses an additional analog
> input to read the battery voltage.
>
> I'd suggest starting with that deign if you want to add capabilities.
>
> On 10/9/20, Max DN <flata...@gmail.com> wrote:
> > Hi all, I hope you are well and healthy.
> >
> > This little project is progressing really well, although not as quick as
> > I'd like to have the time to... I got it all working and it's nice and
> > smooth. However I do have a piece of code which I'm confused about and I
> > was hoping that better trained eyes could help.
> >
> > The code that I'm using (verbatim from here for now:
> > http://www.cathodecorner.com/nwl/nwld1.asm.txt, that is helping me to 
> learn
> >
> > PIC assembly so to write my own code later on) is doing analog conversion
> > of outputs of the accelerometer ADXL335 (datasheet here
> > 
> https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL335.pdf
> )
> >
> > to sense motion / tilt of the wrist. It works beautifully and it's very
> > reliable, coded by DF of Cathode Corner on the X-Y axis (he's also done 
> it
> > on Z-X on another project, so Z should work well on this sensor). My 
> issue
> > is that I have moved the chip such that I need to use Z-X instead of X-Y 
> as
> >
> > in the code. Now that should be an easy code edit... Problem is that I 
> can
> > see the correct mV changes on X-Y-Z on the chip and all pins are
> > individually well connected to the PIC but somehow the PIC ADC isn't
> > picking up Z, so I'm thinking I'm doing something wrong with the channel
> > selection.
> >
> > Schematic here, except pin 8 Z-ADXL which I have actually connected to 
> pin
> > 21 RA4 of the PIC): http://www.cathodecorner.com/nwl/NWLD5schem.pdf
> >
> > X-ADXL connected to AN1 -> So here I should select ADCON0 CH0=1 CH2=0
> > Y-ADXL connected to AN0 -> So here should be ADCON0 CH=0 CH2=0 (X and Y
> > seem switched in the code but given some logic later on, it's fine, no
> > issues so far).
> > Z-ADXL connected to AN4 -> So here I should select ADCON0 CH0=0 CH2=1 
> (but
> > when I do that... it doesn't work, I get 0 voltage sensed, odd)
> > Voltage monitor (resistive divider) connected to AN5 -> now this is odd 
> as
> > I would have expected to select ADCON CH0=1 and CH2=1 but it works only
> > with ADCON0 CH0=0 and CH2=1 (so this is confusing to me! I don't 
> understand
> >
> > why this works only on channel 4 when it's actually connected to channel 
> 5
> > and portA is set as '00110011' (2 and 3 being outputs) with '00110011'
> > (AN0, AN1, AN4, AN5 being analog inputs).
> >
> > Am I missing the obvious elephant in the room? Relevant code below (full
> > code in the link above). I'd appreciate if anyone has 5 mins to spare to
> > look into this please.
> >
> > Thank you,
> > Max
> >
> >
>

-- 
You received this message because you are subscribed to the Google Groups 
"neonixie-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neonixie-l+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/neonixie-l/44e535ab-0b48-4488-8720-7cddc202c779n%40googlegroups.com.

Reply via email to