Gabe Jasso's Build Log

Hi there,

My day job is industrial safety management for a manufacturing company. I got hooked on electronics in a highshcool elective course, then kinda lost touch with it until last year where I made a commitment to learn more. I’ve been learning basic circuit design and microcontrollers from YT and a MAKE book. The CE projects look cool so I plan to try the free ones first. I also have been learning how to program in the FORTH language and use it for programming Arduino and STM32 micros for my projects, which I’ll show in my first project I’ll post here! (Here’s a link to a simple project I made to monitor a water line inside our RV: Arduino Water Alarm

1 Like

Welcome! Another FORTH programmer here. I’ve worked on CForth and Open Firmware, with Mitch Bradley of Firmworks. He used it for the OLPC laptop BIOS, and I tagged along. I’ve also used it with STM32, ESP8266, ESP32, and Teensy. There’s an old interview of me on Embedded FM; https://embedded.fm/episodes/172

2 Likes

Welcome Gabe!

What made you choose FORTH? (same question for @quozl) Previous experience with the language? Something I should check out? I missed James’ episode, I think, or I don’t remember it, I’ll have to go back and listen again.

Forth is fantastic. I wish more people used it. (And now I realise I should be using it more…)

It’s hard to describe exactly what the appeal of it is, but part of it is that it’s a “build your own language” language. By that, I mean that you can, at the same time, in the same language, be twiddling bits in a peripheral register, and writing code that uses high-level application abstractions (that you’ve built).

Another appealing thing is that it is incredibly light-weight. You can bring up a Forth system on more or less any processor that anyone is using (apart from those 3 cent Padauk OTP things…). And the language is set up to be interactive, so once you’ve got a UART going, you can connect to your device and have a conversation. That turns out to be a much more productive way of writing code in many cases than the usual C-style compile-debug cycle. It’s the same sort of thing as you can do with the REPL in Python (or many other languages). But Forth has this immediacy to it that those other languages don’t quite have.

As to whether it’s something you should know about, well… it is a tiny bit weird. It’s very different to other languages, and it will hurt your head to start with.

It was not a choice. It was 1980.

My father, an electrical engineer in transmission grid protection design, borrowed Byte Magazine Volume 05 Number 08 - The Forth Language from the library at work; a government department responsible for building and operating a state electricity grid.

I was in my tenth year of school, and had spent all my free time for a few months learning BASIC, Z80 assembler, and digital electronics. I had a TRS-80 (Model 1 Level II) and could not afford to expand it.

I wrote my own FORTH for the Z80 fairly quickly. In 1983, I wrote my own FORTH for the VAX processor. After that I learned to play with others and use their better work to start with. :grinning:

Since then the situation has changed. Now, I choose FORTH because I know it, I can cram more function into limited space, and I can iterate on debugging without having to edit, compile, load, and test. I agree with @ian; it is a language for writing languages that are a better fit to the problem being solved. Once a language fits the problem domain, expressing the solution is easy and tends to be low in defects. Thinking Forth by Leo Brodie expands on this idea.

Thanks Chris, I’m glad I found CE !!
I choose 4th because I wanted to pick up programming again and happened across a youtuber named 0033mer who used it in his little projects. I like how intuitive and simple it feels and I feel “smart” when I figure out how to enter simple math using RPN. Though I’ve only made simple programs so far, I feel like I really understand the code I write, and it encourages me to keep it simple. I’d definitely recommend you check it out. I really recommend the primer Starting FORTH pdf and also check out the FORTH interest group which has a ton more info:

http://www.forth.org/

-Gabe

I really enjoyed your interview. I like your sentiment at the end of it. I can identify with that feeling of striving for something that seems too difficult at first, but then finally learning it (or at least having new questions). I feel that when I boulder (rock climb) and also in electronics.
-Gabe

Thanks. For those who don’t have the time to listen to the end of it;

Elicia says; “Do you have any last thoughts you’d like to leave us with?”

James says; “Yes, yes, I do, I think, what I’ve learned by having to do everything (last-man standing sustaining engineering), is that … the time you learn is when you are doing something really complicated that you don’t understand, and you get this doubt and fear in your head, “I can’t do this, this just looks wrong, I don’t understand it”, and that’s the best state to be in, if you approach that state with a … a willingness to step through the parts you do understand, and look for ways to explain the parts that are in doubt, then you get out the other side and you do understand it, and so I’m beginning to … to yearn for that state of mind, because that means I’m learning.”

Elicia replies; “That is excellent, very good reminder, I sometimes get in that state and get unhappy, but I think next time I’ll remember what you said and maybe it will make me happier.”


Since then, the sentiment has also connected to the neurological scenario, of oxygen and glucose conserving behaviours, which explains a lot of things about why people find it hard to change their mind in the face of overwhelming physics. Today I’m reading a Australian Royal Commission Report into Natural Disaster Arrangements; and the tremendous cognitive resistance to preparation or evacuation during bushfire is one of my interests.

4 Likes

Just listened. Once of the best Embedded episodes I’ve heard. Nice. And the thought at the end seems exactly right: if you want to learn, get out of your comfort zone and do something hard (for you).

PROJECT #1 TOO HOT! TOO COLD!

SUMMARY: Our circa 1970s apartment has all electric appliances, including electric element heating (non-ventilation heating). The wall thermostat is a dial where you set the desired heat level. Problem is, it’s tough to get the right temp setting in the winter. So I set out to make the automated equivalent of me adjusting the dial all night long to keep a comfortable temp.

PROBLEM: Once set, our older style dial thermostat tries to maintain a constant bedroom temp throughout the night. But in effect, we wake up in the middle of the night saying “its too hot” or “its too cold.”

PROJECT IDEA: Use a microcontroller, temperature sensor, and a servo motor to automate dial turning CW and CCW throughout the night to maintain the heater at a reasonable temperature above the ambient room temp.

IMPLEMENTATION:

  • Texas Instruments Application Note: Thermistor Sensor Circuit
  • Arduino Nano
  • Small Servo
  • FORTH software

Our circa 1970s/80s dial heater thermostat

The dashed lines are the heater settings, so you get to choose only one temp for the entire night sleep

Thermistor circuit I incorporated (I had hoped to use a Maxim 2-wire temp IC, but my skills are not quite high enough to understand the bit banging involved, so I went the sensor-to-ADC route)

Calibrating the thermistor circuit with my decade resistor box

FORTH program:
\ Gabe - Automatic Thermostat (ATmega 328P)
\ Initialize the ADC to output temperature continuously
$40 $7c c!
$f3 $7a c!
\ Set PWM Pin 9 as output and run in Frequency Correct mode
pin9 output
$A0 $80 c!
$12 $81 c!
01001110 $87 c! \ ICR1A setup
00011111 $86 c!
11111 $89 c! \ OCR setup
\ Defines a word “thermo.” Simple loop that adjusts the dial according to desired temperature range
: thermo
cr
begin
$78 @
$175 > if 1500 $88 !
else 900 $88 ! then
again ;
flush

Testing the servo program and thermistor circuit with the heat of my fingers

Bracket for mounting the servo motor to the wall and holding it in place to turn the thermostat dial

Circuits mounted on the wall. Enclosure is a discarded TV dinner tray

Servo motor bracket mounted to wall using 3M dual lock fasteners

Servo horn coupled to the heater dial with a DIY plastic flexible coupling, then to a steel disc and then dual lock onto the dial face

RESULTS:
Well, my family’s gonna be uncomfortable again this winter :sob: My automatic thermostat project failed. The problem seems to be the servo motor-to-thermostat dial alignment is a little too off. So when the servo moves to different rotations, it binds and strains the motor at each new position. I hoped the flexible coupler would resolve it, but no. At this point, I could try adjusting the servo motor centering screw, or making the coupling better aligned, or try a metal gear servo, but I think I’ll throw in the towel. This project taught me how to access Atmel registers to drive a servo, how to follow along with an industrial application note to build an accurate thermistor circuit, how to make a cheap and easy flex coupler, how to build/use a decade box, and sparked a new interest in programmable control (thanks @ian and @kvk ). So it really wasn’t a failure :bridge_at_night:

Sounds like fun. I’ve never been able to solve this one.

One of my attempts at this problem was to add a resistor thermally bonded to the sensor thermistor of a portable heater. Firmware gradually increased the power to the resistor during the night, so as to create a physiological comfort curve rather than constant temperature.

Pituitary and hypothalamus do some sort of prediction of the hours ahead, and if the curve has a dramatic shift all sorts of “wake up” hormones can ensue, with consequent partner stress.

For instance, if your hand-drawn graph was in degrees centigrade, that change in gradient at 3am could wake my wife. :grinning:

1 Like

That’s an interesting solution. I like your creativity of a pseudo comfort regulator. And yes, amazing how our body wakes us when we sense something isn’t right. My solution also was unsuccessful at accomplishing the task … which I’ll explain at the end.

The termostat is probably a P type one. So only proportional regulation. So at a given setting the actual temperature has a wide range. Combined with different temperature of walls makes it difficult if you don’t have intelligent control. PI combined with external temperature measurement solves the issue

1 Like

Thanks for the insight kvk. You’ve sparked my interest now to learn more about this subject of regulation, about P, I PI, and PID. Your comment is much appreciated. -Gabe

If you’re interested in control theory, Brian Douglas’s videos on YouTube are good. It’s a big field, but his approach is a relatively gentle way into it, I think.

1 Like

What’s that? Isn’t constant temperature the most comfortable? I’m lost :crazy_face:

Interesting project overall! I was using mecrisp forth a couple of years ago on stm32 MCUs. Fun stuff, but in the end I found it really, really difficult to get back into some code I wrote a few months prior. It all ends up being too cryptic for me…

1 Like

I’ve not found constant temperature the most comfortable, but I could be unique. :grin: Some random thoughts;

Humans have several internal thermo-regulation systems. There’s the cell level. There’s circulatory controls. There’s breathing controls. There’s sweating. There’s a hormonal release organised by sunlight-detecting timing elements; the circadian rhythm.

Sleep can be easier or more comfortable at particular temperatures relative to the daily experience. My preference is about 18°C, after a day of either 45°C or 5°C.

A constant temperature control in a room does not yield a constant temperature; there are overshoots. As the temperature outside the room falls, the control system tries harder to catch up. Without reticulation, this gives a hot layer hugging the ceiling, and a cold layer hugging the floor. Once the difference is substantial, exposed skin perceives the infra-red from above, and the body seems to take this into account with the air temperature.

For my next attempt at bedroom environment control, I’d capture more than air temperature.

Hey, I didn’t mean to argue, I’m just genuinely curious and am wondering whether I’m missing something :thinking:. Do you know of any studies or other data about what temperature profile is “most comfortable”?

WRT heat stratification, isn’t that a heater design issue, not a temperature control issue? :grin: Of course, you’re probably stuck with the heater you’ve got…

I don’t think I’m arguing, I think I’m over-sharing. :grin:

I did once, but I’ve lost them. A quick look on Google Scholar gives plenty of interesting reading for physiological comfort temperature. At the time I was looking into it, I was a volunteer firefighter in an incident management team communications role; we were tracking wind speed, humidity, cloud cover, temperature, and shift duration to keep crews safe and inform logistics for drinking water and other safety interventions. One of the best interventions was to give the crews hotel accommodation with air conditioning; the volunteer crews worked better if they got good sleep at low temperature.

We’re holding a national inquiry in Australia into aged care at the moment, and health scientists have been talking about thermal control for residents. The inquiry is yet to complete and the interim report doesn’t cover temperature. I heard that “fake” air conditioner remote controls are sometimes used; this gives a sense of agency yet allows the facility to manage energy usage. I also heard about getting the right temperature for people with dementia.

In my experience, comfort comes from;

  • the sense of agency and control; i.e. human accessible controls (clothing choices, position of bed clothes, heating or cooling set points, fan speeds),
  • some form of feedback; i.e. visible display of system configuration, noise of air flow, tell-tail ribbons,
  • an overall system that results in a slowly changing temperature in the desired direction; because no room is sufficiently insulated to entirely overcome the losses, and the body does predict physiological cost of the sleep based on the changing temperature.

Stratification happens by itself unless there is air flow to disrupt it. If you have a thermal camera it is really easy to see. The more air flow you add, the more noise, and in winter there’s the increased skin cooling from the air flow. You’re right it’s not really an issue with temperature control, but more to do with the overall system containing the temperature control, the heating or cooling unit, the room air, the insulation, and the furnishings.

You can achieve close to no apparent stratification; heat the entire floor with a control system that measures floor temperature, insulate the walls, plan for loss of heat through the ceiling. The heated air will rise, cool on the ceiling, and recirculate. The down draft can be kept away using four-poster or canopy beds.

sometimes you just gotta know the search terms… Thanks!!

I have sub-floor radiant heat, really like it :slight_smile: