Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
- HBTE
- Messages
Search
Re: ADE25MH Mixer - warning
#tinysa
Erik,
toggle quoted message
Show quoted text
Primary issue people are facing is how the command interpreter depends on the timing of incoming serial characters. This can be easily solved by storing the incoming characters in a buffer until a '\n' (or some other terminator)? is seen, and only then parsing the command. Jerry On Mon, Jan 27, 2020 at 09:24 AM, Jerry Gaffke wrote: But library functions strtok() and strcmp() are both quite trivial and small. |
Re: ADE25MH Mixer - warning
#tinysa
Erik,
toggle quoted message
Show quoted text
I get that, I've messed with the Nano. As I say, floating point and printf's should be avoided. And the fgets() call in my code sample should be replaced with something appropriate for the Nano serial stream. But library functions strtok() and strcmp() are both quite trivial and small. Using them as shown may well result in less flash and ram consumed than the original code, especially if my extra error checking is removed. Do you ever find a need to use logarithmic sweeps? Sticking with a linear sweep will remove the need for floating point in your code, and will have a significant impact on flash used. Jerry On Mon, Jan 27, 2020 at 08:47 AM, <erik@...> wrote:
Jerry |
New tinySA.exe uploaded
I uploaded a new tinySA.zip with the new exe.
Improvements: - Logging is better split in lines making it easier to understand what is happening - log of {} is now as {} i.s.o b/e -- HBTE Files section:?/g/HBTE/files Erik, PD0EK |
Re: ADE25MH Mixer - warning
#tinysa
Yes, without encoder and display you got it down to 43% program and 74% dynamic memory use..
with full BUFFERSIZE 512.??? THANK YOU! I know about the other log window.. it just says EMPTY. DOES ANYONE ELSE HAVE A NANO talking to the windows tinySA.exe???? 73, Gary WB6OGD |
Re: ADE25MH Mixer - warning
#tinysa
Just got mine in the mail today from huayi-components. It seems that these are refurbished and one of them (lover right corner on the image) has one wire disconnected, so check yours carefully. On Sun, 26 Jan 2020 at 03:15, Dragan Milivojevi? <d.milivojevic@...> wrote:
|
Re: ADE25MH Mixer - warning
#tinysa
Jerry
Some people are using an Arduino nano for tinySA so code space and RAM is very limited. That is why there is so much low level coding -- HBTE Files section:?/g/HBTE/files Erik, PD0EK |
Re: ADE25MH Mixer - actually SA non-operation
The extended log window is in the menu under view/log
-- HBTE Files section:?/g/HBTE/files Erik, PD0EK |
Re: ADE25MH Mixer - actually SA non-operation
Erik,
By "log window", you mean the window on the Settings page, correct? Here is a sample of what mine shows: >>p5 0 >>p6 0 >>v1 >>o444474644 >>v0 >>o433500000 >>w66 >>v1 >>a434474634 >>b454474654 >>t90 >>e-1 >>s300 >>m It looks like it is issuing commands that are correct but nothing is coming back. I can send the same commands via the Arduino IDE Serial Monitor (115200 baud) and get back responses including the data from the scan "{ x...". There is also a pop up loggin window that only shows "Empty". My Nano has a CH340G USB to serial chip with its own driver, looks like your Zero has native USB.. could this be the problem?? When I call up tinySA.exe sometimes it does not find my Nano (COM5), but if I close and reopen then it does... but I get the log above.? I get the graph that is just noise over to the left (same as Dave posted).? Unlike Dave, changing delay to 90, or anything does NOT result in operation. I do have the flaky Serial.available problem still.? I have fixed the P5 so it responds but the "e-1" does result in no response. I am running on a new HP laptop Gen10 i5, Windows10 64bit.? Arduino Nano clone CH340G USB to serial, no encoder or display, pins re-assigned by me.? ADE25 mixer, PE4302 parallel, FET level shift board on SPI pins, series LED level drop on PE pins.? Works fine in Signal Gen mode using Serial Monitor commands. 73, Gary WB6OGD |
Re: ADE25MH Mixer - actually SA non-operation
When I scan 100 points I get this in the log window
----------------------log start ------------------------- <<VFO: 1__Output frequency: 443900443__
<<e
<<x6?
<<x6?
>>o443900443
>>v1
<<x6?
<<x6?
<<x9?
<<x9?
<<x9?
<<x9?
<<x12?
<<x9?
<<x9?
<<x9?
<<x9?
<<x9?
<<x12?
<<x12?
<<x15?
<<x15?
<<x15?
<<x19?
<<x16?
<<x28?
<<x73?
<<x85?
<<x68?
<<x50?
<<x24?
<<x9?
<<x12?
<<x9?
<<x6?
<<x9?
<<x12?
<<x12?
<<x6?
<<x6?
<<x6?
<<x9?
<<x16?
<<x13?
<<x12?
<<x12?
<<x9?
<<x6?
<<x6?
<<x9?
<<x6?
<<x6?
<<x6?
<<x9?
<<x9?
<<x9?
<<x6?
<<x9?
<<x6?
<<x9?
<<x9?
<<x9?
<<x9?
<<x6?
<<x12?
<<x15?
<<x12?
<<x9?
<<x10?
<<x12?
<<x13?
<<x15?
<<x15?
<<x24?
<<x24?
<<x24?
<<x24?
<<x24?
<<x24?
<<x25?
<<x25?
<<x21?
<<x33?
<<x27?
<<x33?
<<x24?
<<x30?
<<x24?
<<x30?
<<x24?
<<x30?
<<x37?
<<x33?
<<x33?
<<x39?
<<x36?
<<x34?
<<x47?
<<x53?
<<x51?
<<x61?
<<x104?
<<x116?
<<x77?
<<Steps: 100__{__
<<a VFO: -1__
<<x29300?
<<Start: 433900433__Stop: 453900453__time pr step: 10__E
>>m
>>s100
<<VFO: 0__Output frequency: 433900000__Width: 10000__VFO: 1__
>>a433900433
>>v1
<<Parameter? 6 = 0__VFO: 1__Output frequency: 443900443__
>>v0
<<Parameter? 5 = 0__
>>p6 0
>>p5 0
<<VFO: 1__Output frequency: 443900443__
---------------------- log end --------------------- HBTE Files section:?/g/HBTE/files Erik, PD0EK |
Re: ADE25MH Mixer - warning
#tinysa
Here's some cleaner code, a working program for linux to demo strtok()
in a way that I thing it could be used in the tinySA. Also shows a clean and portable way to read integers. All of it can gracefully deal with most errors. Entire thing should port directly to arduino, except arduino has no main() of course. Calls to printf() are best avoided on something like a Nano, as that function tries to do everything and thus burns a lot of flash. Also, those on a Nano should avoid the use of floating point, for the same reason. If only linear sweeps are to be made (not logarithmic), then tinySA.ino need not use any floating point. (Logarithmic sweeps can also be accomplished using 64 bit long-long fixed point, but that also burns lots of flash.) Question:? Are logarithmic sweeps a desired feature???? //################################################# #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
?
#define LNBUFSZ 82? ? ? ? ? ? ? // 80 chars plus two for \n and \0
?
char atoix_err = 0;? ? ? ? ? ? ?// Main program can occasionally check this
// Convert string to long in base 8 (0NNN),10 (NNN) or 16 (0xNNN)
long atoix(char *str) {
? ? char *endstr;
? ? long rval;
? ? // errno = 0;
? ? rval = strtol(str, &endstr, 0);
? ? if (*str=='\0' || *endstr!='\0')? ?{
? ? ? ? fprintf(stderr, "ERROR, atoix() expected an octal/decimal/hex number: %s\n", str);
? ? ? ? rval=0;
? ? ? ? atoix_err = 1;? ? ? ? ? // Can set to zero before calling atoix()
? ? }
? ? return(rval);
}
void main() {
? ? char linebuf[LNBUFSZ];
? ? // char* token1;? char* token2; char* token3;
? ? char *token1, *token2, *token3;
? ? int addr, data;
? ? while (1) {
? ? ? ? fgets(linebuf, LNBUFSZ, stdin);? ? ? ? ?// Read chars through a '\n'
? ? ? ? token1 = strtok(linebuf, " \t\n");? ? ? // Find the first token
? ? ? ? if (token1==NULL)? continue;
? ? ? ? if (!strcmp(token1,"x")) {? ? ? ? ? ? ? // Register read/write command
? ? ? ? ? ? token2 = strtok(NULL, " \n\t");? ? ?// Find the second token
? ? ? ? ? ? if (token2 != NULL) {
? ? ? ? ? ? ? ? addr = atoix(token2);
? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? printf("%s", "Error, expected one or two args for command x \n");
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? }
? ? ? ? ? ? token3 = strtok(NULL, " \n\t");? ? ?// Find the third token
? ? ? ? ? ? if (token3 != NULL) {
? ? ? ? ? ? ? ? data = atoix(token3);
? ? ? ? ? ? ? ? printf("regwrite %d %d \n", addr, data);
? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? printf("regread %d \n", addr);
? ? ? ? ? ? }
? ? ? ? } else if (!strcmp(token1,"hcf"))? {
? ? ? ? ? ? printf("halt_and_catch_fire() \n");
? ? ? ? } else if (0) {? ? ? ? ?// any other commands go here
? ? ? ? ? ? ? ? // ...
? ? ? ? } else if (!strcmp(token1,"q"))? {
? ? ? ? ? ? exit(0);
? ? ? ? } else {
? ? ? ? ? ? printf("Error, bad command \n");
? ? ? ? }
? ? }
}
//##################################################
On Sun, Jan 26, 2020 at 09:11 AM, Jerry Gaffke wrote:Jerry, KE7ER I'm trying to port tinySA.ino over to the RPi. |
Re: ADE25MH Mixer - warning
#tinysa
Mixer problem - SOLVED
The ADE25 mixers are fine.? They work in a different way to the ADE1 and needed a capacitor to decouple from the 3dB pad.? The ADE1 have transformers, so no problem.? A good learning experience. The spurs at the harmonic frequencies are I think really are there.? If spur reduction is turned on the levels of the harmonics and the fundamental change significantly each scan, so the readings cannot be trusted.? I can see the harmonic on my Hermes Lite 2 SDR. If I run the signal through a low pass filter then the levels of the harmonics in Tiny-SA drop significantly, but they are still present.? Interestingly the Nano-VNA measures the attenuation by the filter at the harmononic frequency of around 30 db, but the signal on the spectrum only drops by half that.? Further investigation needed.? Adding a fixed 15db attenuator drops all the signals by roughly that amount. 73 Dave M0WID |
Re: ADE25MH Mixer - actually SA non-operation
I am seeing the exact thing.
It seems like the .exe program is not communicating with the SA hardware. The log file is empty, the log window under settings shows the commands I would expect being sent to the hardware, BUT, it shows nothing coming back. I can send the same commands via the Serial Monitor and it looks like it works fine.. lots of readings coming back from the scan. BTW, I got my ADE-25 on a board(module) from ebay chinese seller. I have confirmed it works via signal generator mode (via commands sent through Serial Monitor). 73, Gary WB6OGD |
Re: ADE25MH Mixer - warning
#tinysa
The command parser is bit error prone when single characters are send
It only works correct if whole lines are send one USB transaction Something to improve -- HBTE Files section:?/g/HBTE/files Erik, PD0EK |
Re: ADE25MH Mixer - warning
#tinysa
Thanks for the Replies
See screen shots below: After the TinySA.exe gets to this state then the display freezes. You can change settings etc, press single or run again, and the ESP32 responds (led comes on as data is sent), but the Analyser display is frozen.? Exiting the application and restarting, setting Speed to 90 and all works fine.? No need to reset the ESP32. Maybe I am missing it but I cannot see a way to view the responses from the ESP32 - the View log always return empty.? Is there perhaps something odd happening in my PC? The ADE25 ebay supplier was also huayi-components.? I will do another test by replacing the ADE 1 that is working fine with each of the five ADE25 I have and report back.? Maybe I have just been unlucky.? I should add that I have added a 3dB pad between the mixer and the B3555 filters, but that is common to both types of mixer so is unlikely to be a problem. The AD9850 actually has a MMIC on the output, so I think the harmonics are coming from that and are real.? Again I will test by adding a low pass filter and see if they disappear. |
Re: ADE25MH Mixer - warning
#tinysa
I seem to be having a similar problem.? I am trying to run on an Arduino Nano (clone) with Arduino IDE 1.8.
And trying commands using the Serial Monitor. The serial receive code is inconsistent, for instance between 'G' command and 'P': ? if(inData == 'G' || inData == 'g') ? { ??? spacing = Serial.parseInt(); ? if(inData == 'P' || inData == 'p') ? { ??? if(Serial.available()>0) { ???? parameter = Serial.parseInt(); The extra if (Serial.available)? causes a problem for some reason. Eliminating it like in the 'G' command seems to fix it for me. 73, Gary WB6OGD |
Re: ADE25MH Mixer - warning
#tinysa
If you're old enough, you will recognize??"halt_and_catch_fire"
as opcodes 0x9d and 0xdd on the Motorola 6800. Opcode mneumonic of "HCF". |
Re: ADE25MH Mixer - warning
#tinysa
I'm trying to port tinySA.ino over to the RPi.
toggle quoted message
Show quoted text
Appears that the serial command interpreter is highly dependent on the timing of each incoming character. A better way to do this is to wait for a '\n' character to indicate a complete command before processing it. And I'd separate each line into tokens with whitespace, either spaces or tabs. So to write 34 to register 12, the 'x' command becomes the character sequence? "x 12 34\n" Any extra whitespace is ignored:? "x? ? ? 12? ?\t 34? \t? ?\n" The C strings library makes this easy, code looks something like this. Note that each call to strtok() is modifiying linebuf[] by placing a '\0' after the next token, then returning a pointer for the start of that token within linebuf[] #include <strings.h> #define LNBUFSZ 82? ? ? ? ? ? ? // 80 chars plus two for \n and \0 void main() { ? ? char linebuf[LNBUFSZ];? ? ? char* token; ? ? while (1) { ? ? ? ? fgets(linebuf, LNBUFSZ, stdin);? ? // Read chars up to and including the next '\n'
? ? ? ? token = strtok(linebuf, " \t\n");? ? ? ? ? ? ? //? Any whitespace of spaces, tabs or newlines is not a token
? ? ? ? if (!strcmp(token,"x")) {? ? ? ? ? //? "x? addr" to read a register,? ?"x addr data" to write
? ? ? ? ? ? int regaddr, regdata;
? ? ? ? ? ? token = strtok(NULL, " \n\t");? ? // NULL says to continue operating on the same string
? ? ? ? ? ? if (token!=NULL)? regaddr = atoi(token);? else { print("Error, no args to command x \n"); break; }
? ? ? ? ? ? token = strtok(NULL, " \t\n");
? ? ? ? ? ? if (token!=NULL)? regwrite(regaddr, atoi(regdata));? ? else { print(atoi(regread(addr))); } ? ? ? ? } else if (!strcmp(token,"h"))? halt_and_catch_fire(); ? ? ? ? } else { ? ? ? ? ? ? ? ? ... ? ? ? ? } else print("Error, bad command \n"); ? ? } } ? ??
Jerry, KE7ER ?
On Sat, Jan 25, 2020 at 06:08 PM, m0wid wrote:When testing with the Arduino terminal commands the ESP32 responds as you would expect, but when driven by the TinySA.exe TinySA.exe hung after around 100 samples.? |
Re: ADE25MH Mixer - warning
#tinysa
Nice work!
3000 points will always be slow. For this kind of measurements 300 or 1000 at most should be enough. Max RBW =600kHz Can you set Average to "min: and enable spur reduction and see if the peaks that should not be there disappear? ADE-25MH should be same size as ADE-1 Enable view/logging, set points to 100, scan to full speed and see what is going wrong in the communication -- HBTE Files section:?/g/HBTE/files Erik, PD0EK |
to navigate to use esc to dismiss