¿ªÔÆÌåÓý

doTuning() mod, utility, vanity


 


A few simple mods to the sketch in the doTuning function can add some utility and a little vanity.? doTuning() is near the end of the sketch.

1. Add a line to print left or right arrows to show when the tuning is in shift mode at the far ends of the tuner????? printLine2((char *)"<<<<<<<<<<????? ");

2. Increase the delay in milliseconds to allow for reaction to shift mode before it goes to far.????????? delay(400);

3. Add a line to print "BITX40 ** YOUR_CALL" that will show up whenever you are listening or tuning the dial.???????? printLine2((char *)"BITX40 ** KC8WBK");

The display will show 16 characters, so don't enter more than 16.
?
void doTuning() {
?
? long knob = knob_position(); // get the current tuning knob position
?
? // the knob is fully on the low end, move down by 10 Khz and wait for 200 msec
? if (knob < -80 && frequency > LOWEST_FREQ) {
??? baseTune = baseTune - 10000L;
??? frequency = baseTune + (50L * knob * TUNING_RANGE / 500);
??? printLine2((char *)"<<<<<<<<<<????? ");
??? updateDisplay();
??? setFrequency(frequency);
??? delay(400);
? }
?
? // the knob is full on the high end, move up by 10 Khz and wait for 200 msec
? else if (knob > 10120L && frequency < HIGHEST_FREQ) {
??? baseTune = baseTune + 10000L;
??? frequency = baseTune + (50L * knob * TUNING_RANGE / 500);
??? printLine2((char *)"????? >>>>>>>>>>");
??? setFrequency(frequency);
??? updateDisplay();
??? delay(400);
? }
?
? // the tuning knob is at neither extremities, tune the signals as usual ("flutter fix" by Jerry, KE7ER)
? else if (knob != old_knob) {
??? static byte dir_knob;
??? if ( (knob > old_knob) && ((dir_knob == 1) || ((knob - old_knob) > 5)) ||
???????? (knob < old_knob) && ((dir_knob == 0) || ((old_knob - knob) > 5)) )?? {
????? if (knob > old_knob) {
??????? dir_knob = 1;
??????? frequency = baseTune + (50L * (knob - 5) * TUNING_RANGE / 500);
????? }
????? else {
??????? dir_knob = 0;
??????? frequency = baseTune + (50L * knob * TUNING_RANGE / 500);
????? }
????? old_knob = knob;
????? setFrequency(frequency);
????? printLine2((char *)"BITX40 ** KC8WBK");
????? updateDisplay();
??? }
? }
?
? if (vfoActive == VFO_A)
??? vfoA = frequency;
? else
??? vfoB = frequency;
}


 

Paul,

your idea is a "nice-to-have" one, but unfortunately we're running out of
memory:

original sketch v1.13:

Sketch uses 26886 bytes (87%) of program storage space. Maximum is 30720
bytes.
Global variables use 1521 bytes (74%) of dynamic memory, leaving 527 bytes
for local variables. Maximum is 2048 bytes.

updated sketch:

Sketch uses 26944 bytes (87%) of program storage space. Maximum is 30720
bytes.
Global variables use 1555 bytes (75%) of dynamic memory, leaving 493 bytes
for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.

It's caused by the 3 printLine2 commands that consume a lot of RAM.

73 Allard PE1NWL


Jack Purdum
 

All:

In Allard's defense, it's even worse than he's letting on. Using 87% of the Flash memory is running on the edge, but is probably okay. The really scary statistic is the 74% on the SRAM memory. Recall that all of the data is stored in SRAM and the 74% number is the compile-time use statistic, not the run-time use. As the program runs and functions are called, each of which likely passes more data to the function during the call, the stack memory, which is part of SRAM, is getting skinnier and skinner. Think of a stack of dinner plates. The bottom of SRAM is called the "heap" and that were the global data are stored. So Allard may have several hundred plates at the bottom of the stack already used (i.e., dirty dinner plates!). As temporary data are define in functions and during calls, plates are removed from the stack and used...the unused stack of plates is getting skinnier. That 74% figure is the picture of the dinner plate stack before the restaurant doors are even opened...it's a compile-time statistic. When the program runs, it's like opening the restaurant doors to a bunch of football teams.?

My own experience was that I started getting erratic behavior when I was running around 72% of SRAM memory for one of my programs. (I was using some large graphics temporary variables in SRAM.) What Allard has shoehorned into the Nano is amazing. So, don't let those percentages fool you. He been doing a tight rope act over the Grand Canyon for quite some time now.

Jack, W8TEE?



From: Allard PE1NWL <pe1nwl@...>
To: [email protected]
Sent: Saturday, May 27, 2017 3:48 PM
Subject: Re: [BITX20] doTuning() mod, utility, vanity

Paul,

your idea is a "nice-to-have" one, but unfortunately we're running out of
memory:

original sketch v1.13:

Sketch uses 26886 bytes (87%) of program storage space. Maximum is 30720
bytes.
Global variables use 1521 bytes (74%) of dynamic memory, leaving 527 bytes
for local variables. Maximum is 2048 bytes.

updated sketch:

Sketch uses 26944 bytes (87%) of program storage space. Maximum is 30720
bytes.
Global variables use 1555 bytes (75%) of dynamic memory, leaving 493 bytes
for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.

It's caused by the 3 printLine2 commands that consume a lot of RAM.

73 Allard PE1NWL







 

This is a mod that an individual could add.??? It was intended as a way that the user could customize the radio.

If memory is a problem, then perhaps have multiple versions, for example,? I currently don't use USB, CW, or RIT.? I may want them in a future build but would rather have a stable sketch? without them, if memory is low.? So today I select a minimal version and later if I build a multiband rig I select a version with USB or other features.


 

Meanwhile I managed to free up some space by removing some other less
useful stuff, and so I could include your extra printLine2 commands.
Thanks for sharing your idea!
Will be included in the next release v1.14.

73 Allard PE1NWL

On Sun, May 28, 2017 02:31, KC8WBK via Groups.Io wrote:
This is a mod that an individual could add.?????? It was intended as a way
that the user could customize the radio.

If memory is a problem, then perhaps have multiple versions, for
example,?? I currently don't use USB, CW, or RIT.?? I may want them in a
future build but would rather have a stable sketch?? without them, if
memory is low.?? So today I select a minimal version and later if I build
a multiband rig I select a version with USB or other features.


 

Speaking of memory issues, one might think it was time to move to a ARM Feather -- same small form factor, 32 bit CPU and lots Flash/RAM.? Works with the Arduino IDE (as do several other small form factor M0 devices).



Of course Jack is part way there with the 8-bit AVR 2560 micro. ?

Drawback of the M0 Feather is 3.3 volt logic.? But it has higher resolution A/D converters, and a real D/A converter (think sine wave vs. square wave sidetone).? Running I2C peripherals like the 5351 or a TFT display negates the issue with 3.3 volts.

Anyway, Allard is working miracles with limited memory resources for sure.

73, Bob, WB4SON


 

Bob:

There are several other options like the PIC32 based Fubarino Mini(32 Bit, 40 MHz, massive RAM & Flash).

And like you pointed out there is the 5v/3.3v issues. There are also pinout issues, delay loop timing, and more importantly library incompatibilities. Many "standard" Arduino libraries do direct Atmel register access that won't run on other architectures. There are hundreds of posts on the chipKIT Forum from folks having trouble using Arduino libraries on the PIC32 family of chipKIT boards. You can't assume it will work across processor architectures. Some library rewriting/porting may be required. As they say YMMV...

That said, with good Eagle-Fu you could layout your own 32 Bit "Raduino" on an architecture of your choice.

James
KE4MIQ