Other Parts Discussed in Thread: PGA460, ENERGIA
Hello,
I've been working with these boards on a project for a little while now, but I still cannot get Energia to give me the same distance values as the GUI. To keep it simple, I'll just show the mismatch through the GetDistance sketch instead of BusDemo. I'll talk through each prompt and what I've done in the PGA460_USSC.cpp file to try to get them to match. I am using the transformer-driven closed-top transducer. I am using OWU (set up according to the busdemo video that Akeem has sent to me previously). I have the board set to address 0. I always program EEPROM before switching to Energia.
First, here's what the Data Monitor in the GUI gives me for my small object at an easy position to detect:
As you can see, I can get a very consistent 0.380-0.381m distance value. The noise floor is sufficiently below the constant threshold line that I never get a false positive when my object is at that position. Everything is perfect for what I need.
Next, I wanted to make sure I put the values used in the GUI into Energia, through PGA460_USSC.cpp. I read the values from the memory map in the GUI (attached below), then used those values in presets in the .cpp file. I changed case 0 of the .cpp file for threshold and TVG to make things easy.
Here is the memory map from GUI:
;GRID_USER_MEMSPACE 00 (USER_DATA1),88 01 (USER_DATA2),88 02 (USER_DATA3),88 03 (USER_DATA4),88 04 (USER_DATA5),88 05 (USER_DATA6),88 06 (USER_DATA7),39 07 (USER_DATA8),CE 08 (USER_DATA9),73 09 (USER_DATA10),C2 0A (USER_DATA11),10 0B (USER_DATA12),80 0C (USER_DATA13),80 0D (USER_DATA14),80 0E (USER_DATA15),80 0F (USER_DATA16),00 10 (USER_DATA17),00 11 (USER_DATA18),00 12 (USER_DATA19),00 13 (USER_DATA20),00 14 (TVGAIN0),60 15 (TVGAIN1),12 16 (TVGAIN2),8A 17 (TVGAIN3),00 18 (TVGAIN4),0E 19 (TVGAIN5),FD 1A (TVGAIN6),FC 1B (INIT_GAIN),F3 1C (FREQUENCY),90 1D (DEADTIME),00 1E (PULSE_P1),85 1F (PULSE_P2),12 20 (CURR_LIM_P1),7F 21 (CURR_LIM_P2),FF 22 (REC_LENGTH),0C 23 (FREQ_DIAG),00 24 (SAT_FDIAG_TH),EE 25 (FVOLT_DEC),7C 26 (DECPL_TEMP),0A 27 (DSP_SCALE),00 28 (TEMP_TRIM),00 29 (P1_GAIN_CTRL),00 2A (P2_GAIN_CTRL),00 2B (EE_CRC),7E 40 (EE_CNTRL),04 41 (BPF_A2_MSB),8B 42 (BPF_A2_LSB),86 43 (BPF_A3_MSB),F3 44 (BPF_A3_LSB),72 45 (BPF_B1_MSB),06 46 (BPF_B1_LSB),47 47 (LPF_A2_MSB),7C 48 (LPF_A2_LSB),D3 49 (LPF_B1_MSB),01 4A (LPF_B1_LSB),97 4B (TEST_MUX),00 4C (DEV_STAT0),80 4D (DEV_STAT1),00 5F (P1_THR_0),88 60 (P1_THR_1),88 61 (P1_THR_2),88 62 (P1_THR_3),88 63 (P1_THR_4),88 64 (P1_THR_5),88 65 (P1_THR_6),39 66 (P1_THR_7),CE 67 (P1_THR_8),73 68 (P1_THR_9),C2 69 (P1_THR_10),10 6A (P1_THR_11),80 6B (P1_THR_12),80 6C (P1_THR_13),80 6D (P1_THR_14),80 6E (P1_THR_15),00 6F (P2_THR_0),88 70 (P2_THR_1),88 71 (P2_THR_2),88 72 (P2_THR_3),88 73 (P2_THR_4),88 74 (P2_THR_5),88 75 (P2_THR_6),39 76 (P2_THR_7),CE 77 (P2_THR_8),73 78 (P2_THR_9),C2 79 (P2_THR_10),10 7A (P2_THR_11),80 7B (P2_THR_12),80 7C (P2_THR_13),80 7D (P2_THR_14),80 7E (P2_THR_15),00 7F (THR_CRC),9A EOF
And here is the threshold preset 0 in the .cpp file. As you can see, I copied these values to both preset 1 and 2, since I just need the system to work with these specific values reliably.
void pga460::initThresholds(byte thr) { switch (thr) { case 0: //Copy of Custom from GUI (Old was 25%) P1_THR_0 = 0x88; P1_THR_1 = 0x88; P1_THR_2 = 0x88; P1_THR_3 = 0x88; P1_THR_4 = 0x88; P1_THR_5 = 0x88; P1_THR_6 = 0x39; P1_THR_7 = 0xCE; P1_THR_8 = 0x73; P1_THR_9 = 0xC2; P1_THR_10 = 0x10; P1_THR_11 = 0x80; P1_THR_12 = 0x80; P1_THR_13 = 0x80; P1_THR_14 = 0x80; P1_THR_15 = 0x00; P2_THR_0 = 0x88; P2_THR_1 = 0x88; P2_THR_2 = 0x88; P2_THR_3 = 0x88; P2_THR_4 = 0x88; P2_THR_5 = 0x88; P2_THR_6 = 0x39; P2_THR_7 = 0xCE; P2_THR_8 = 0x73; P2_THR_9 = 0xC2; P2_THR_10 = 0x10; P2_THR_11 = 0x80; P2_THR_12 = 0x80; P2_THR_13 = 0x80; P2_THR_14 = 0x80; P2_THR_15 = 0x00; break;
For the prompts:
I am using OWU and so prompt 1 is 2.
Prompt 2 is 9.6kbaud to match the serial monitor.
Prompt 3 is 0 to use the Threshold preset I showed above.
I skip prompt 4 since I prefer to use my own settings set in the GUI (currently 58.8kHz, 5 pulses, 500mA). Are these values not being used by Energia? I'm just trying to think where things might go wrong, and I know all 3 of these values get reset when I re-flash the board in the GUI.
For prompt 5, I use 3 since that is the same range displayed in the GUI.
Prompt 6, I do the same as for the threshold values and choose preset 0. Below is the rewritten preset 0:
//Set fixed AFE gain value switch (tvg) { case 0: //CUSTOM FROM GUI OLD:25% Level TVGAIN0 = 0x60; TVGAIN1 = 0x12; TVGAIN2 = 0x8A; TVGAIN3 = 0x00; TVGAIN4 = 0x0E; TVGAIN5 = 0xFD; TVGAIN6 = 0xFC; break;
For prompt 7, I choose 2 just to avoid the transmission burst giving me a false positive.
Prompt 8 is 0.
Prompt 9 is 0.
Prompt 10 is 0.
Prompt 11 is 5 for some arbitrary delay.
Prompt 12 is 1.
Prompt 13 is 0.
I then receive these very strange distance values in the serial monitor. The object and transducer/board have not been moved at all.
Any idea why P1 is not displaying anything, and P2 is giving varying distances?
The code shows that P1 is used first, then P2 is run if nothing is detected. However, both of my threshold presets use the exact same values now (copied from the GUI). Or am I misunderstanding what P1 and P2 mean here? Are P1 and P2 not the threshold presets? Are some other values than just threshold values being changed depending on which preset is used? If that is the case, how can I go about matching what the GUI does?
My goal is simply to replicate what I get through the GUI (hopefully soon on 4 boards using BusDemo). Again, I copied the GUI threshold values to both P1 and P2 of preset 0, since those are the only values I will need for now (constant 56).
Are the threshold/gain values I input not being used? Is the 58.8kHz, 5 pulse count, and 500mA from the GUI not being used? Any other ideas?