Hi
I want to generate two different signals on DAC1 and DAC2 , but I have problem, because always I have identical signal on DACs, why ?
For example I have as below, but always I have voltage from DAC1DATL on DAC2 :
Well that is a new chip. And, it may have support issues. When I release support I did write 30 demos but I did not test/try the DAC.
But, looking at PICINFO. I see that DAC1 has two registers DAC1DATH:DAC1DATL and DAC2 as DAC2DAT. So, these two DACs ( of three ) are not the same. What is the diiference?
So, for DAC1 you need to see two registers, and, for DAC2 one registers.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I also tried with DAC2 and DAC3, according to the datasheet for 8bit DAC and it still generates the same voltages on the two DACs.
You could test it on your hardware.
Last edit: Boguslaw 2023-12-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are 3 DACs on the Q71... DAC1 (10-bit) and DAC2, DAC3 (both 8-bit).
They all share the same 2 output pins (RA2 or RB7), selectable via the OE bits of the DACxCON registers. The datasheet has this note:
This device has multiple DACs that share the same output pin. If more than one DAC is enabled
simultaneously, the priority for the DACOUT pin is DAC1>DAC2...>DACn.
If you want to use all three DACs you could route one of them through one of the OPAMPs to get the output on OPA1OUT (RA1) or OPA2OUT (RB1) instead of enabling its output pin.
👍
2
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
using the output on RB7 since that pin is also the builtin debugger/programmer ICSPDAT.
[RANT]
They do this on a lot of the new chips... mixing the analog functions with the ICSP pins. Since you can't move the analog pins this makes the analog functions unusable while you have the programmer/debugger connected! Why they choose to do this is beyond me. [/RANT]
@Evan - next time you talk to your contacts @mchip you might ask them why they do this instead of using some of the digital pins for the ICSP connection. At least those you can route with PPS.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The program generates a Sine Wave ( works on the LGT).
I have ported this but I am not sure what we would set on the Q71. The LGT used the DALR register. The readtable command sets the DALR.
Are you able to get this working?
Evan
#chip18F56Q71#optionexplicit// ------ Start of main ProgramDimDACCounterasByte#defineSAMPLES33#defineDACPORTPORTA.1DIRDACPORTOUT// OPA1 output RA1OPA1CON0=0xA8// UNITY GAINOPA1CON1=0x00OPA1CON2=0x04// DAC1// DAC1CON (ena, no output pin)DAC1CON=0x80Do/* Ramp up and down by reading the table data and setting the DAC register DAC data register, setting output voltage in DAC mode Relationship between DAC output voltage and DALR: VDAO = VREF*(DALR + 1)/256 VDAO indicates DAC output analog voltage VREF indicates reference voltagesource, which is set by DAVS of DACON register */forDACCounter=1to33ReadTableSineWaveDAta,DACCounter,DALRnextLoop// Sine wave sample DAC setting valuesTableSineWaveData0x80,0x98,0xb0,0xc6,0xda,0xea,0xf5,0xfd,0xff0xfd,0xf5,0xea,0xda,0xc6,0xb0,0x98,0x80,0x670x4f,0x39,0x25,0x15,0x0a,0x02,0x00,0x02,0x0a0x15,0x25,0x39,0x4f,0x67,0x80EndTable
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Evan,
I'll check that out when I get a chance... sort of busy at the moment.
I take back come of what I said in my previous post. While I can route DAC1 out the OPA1OUT, there's still some sort of funny interaction between the DACs... I can't get more than 1 DAC working at a time.
I don't know if it has to do with using the 18F56Q71 Curiosity Nano and its builtin debugger or not.
I have some 26Q71 around here somewhere... I'll try the same thing using it standalone and see if it's a debugger limitation or what. Different chip, but that's all I got atm.
Last edit: Jerry Messina 2023-12-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I want to generate two different signals on DAC1 and DAC2 , but I have problem, because always I have identical signal on DACs, why ?
For example I have as below, but always I have voltage from DAC1DATL on DAC2 :
Thanks
Boguslaw
Last edit: Boguslaw 2023-12-20
Welcome,
Not sure you have the chip correct. a 18F56 ?
Without the chip type it is hard to help.
I have board PIC18F56Q71 Curiosity Nano
and I use: #chip PIC18F56Q71,64
Well that is a new chip. And, it may have support issues. When I release support I did write 30 demos but I did not test/try the DAC.
But, looking at PICINFO. I see that DAC1 has two registers DAC1DATH:DAC1DATL and DAC2 as DAC2DAT. So, these two DACs ( of three ) are not the same. What is the diiference?
So, for DAC1 you need to see two registers, and, for DAC2 one registers.
DAC1DATH=0 and DAC2DATH=0 because I use 8bit values 0-255
DACxDATH: Accesses the upper 2 bits of DACR
DACxDATL: Accesses the lower 8 bits of DACR
Last edit: Boguslaw 2023-12-20
DAC1DATL=0 and DAC2DATL=0 surely?
Gives...
"message": "Variable DAC2DATH was not explicitly declared",
I use SYNWRITE, this compiler not report any error, should I use another compiler?
Probably 8bit DAC use DAC2 DAC3 names (according to datasheet)
Last edit: Boguslaw 2023-12-20
I am not sure.
Show me the top line of the ASM file being produced, please.
Last edit: Boguslaw 2023-12-20
One line...
OK you are on one of the latest builds.
You have
#option explicit
missing from your program. Add please. You will get the error.DAC2DATH is being created as a RAM variables. I am not sure what the others are.
Try using GCODE as your IDE. It is a lot better and that is where all our development is happening.
Sorry , I pasted wrong listing ,now is corrected,
Yes now I have error with #option explicit but now I test with 8 bit values
Last edit: Boguslaw 2023-12-20
I don't know how use GCODE I'm a beginner in GCBasic
:-)
So, you are now setting the L registers. My assumption.
So, I think you have to study the datasheet to figure the registers.
But, a thought. You are allowing the chip to go to sleep. Put this at the end of your code. This will prevent sleep.
I have below listing with do loop
Last edit: Boguslaw 2023-12-20
I also tried with DAC2 and DAC3, according to the datasheet for 8bit DAC and it still generates the same voltages on the two DACs.
You could test it on your hardware.
Last edit: Boguslaw 2023-12-20
I think that you can only enable one at a time, see page 831.
I may be wrong but this looks like one DAC on multiple selectable outputs.
And, I can tell you are no beginners to microcontrollers. :-)
There are 3 DACs on the Q71... DAC1 (10-bit) and DAC2, DAC3 (both 8-bit).
They all share the same 2 output pins (RA2 or RB7), selectable via the OE bits of the DACxCON registers. The datasheet has this note:
If you want to use all three DACs you could route one of them through one of the OPAMPs to get the output on OPA1OUT (RA1) or OPA2OUT (RB1) instead of enabling its output pin.
If you're using the Q71 Curiosity Nano you may have a problem using the output on RB7 since that pin is also the builtin debugger/programmer ICSPDAT.
Try routing DAC1 through the OPA instead.
quoting myself...
[RANT]
They do this on a lot of the new chips... mixing the analog functions with the ICSP pins. Since you can't move the analog pins this makes the analog functions unusable while you have the programmer/debugger connected! Why they choose to do this is beyond me.
[/RANT]
@Evan - next time you talk to your contacts @mchip you might ask them why they do this instead of using some of the digital pins for the ICSP connection. At least those you can route with PPS.
@Jerry.
I agree! I understand and I will.
"Try routing DAC1 through the OPA instead." this is hard for implementation for me now.
I'll try to experiment.
Last edit: Boguslaw 2023-12-20
Using the 18F56Q71 Curiosity Nano I get the same results as you... can't use RB7 as an output.
You can route DAC1 through OPA1 (output on RA1) using
Jerry,
Can the Q71 do that same with the DAC as the LGT?
The program generates a Sine Wave ( works on the LGT).
I have ported this but I am not sure what we would set on the Q71. The LGT used the DALR register. The readtable command sets the DALR.
Are you able to get this working?
Evan
Evan,
I'll check that out when I get a chance... sort of busy at the moment.
I take back come of what I said in my previous post. While I can route DAC1 out the OPA1OUT, there's still some sort of funny interaction between the DACs... I can't get more than 1 DAC working at a time.
I don't know if it has to do with using the 18F56Q71 Curiosity Nano and its builtin debugger or not.
I have some 26Q71 around here somewhere... I'll try the same thing using it standalone and see if it's a debugger limitation or what. Different chip, but that's all I got atm.
Last edit: Jerry Messina 2023-12-21
OK. Understand.
It would be good to get that demo working.