Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Wandering Orange
Sep 8, 2012

Brain fog sanity check: If I connect a fixed 500Hz PWM signal (0-5VDC, 16-bit) to a standard hobby servo motor then I'll have full control so long as I set the PWM to between 50 and 100%, right? The servo motor expects 1 to 2ms pulse widths for full arm movement so with 500Hz signal, 50% PWM is 1ms and 100% PWM is 2ms.

Adbot
ADBOT LOVES YOU

Stack Machine
Mar 6, 2016

I can see through time!
Fun Shoe
The last servos I played with liked having a good long period of like 20ms with short 1ms-2ms pulses, so you might do better configuring it to 50Hz and using a range of 3277-6554 instead.

Unperson_47
Oct 14, 2007



I think I want to get into learning how to program microprocessors to make standalone PCBs for little electronic projects and stuff so I don't have to use a RaspberryPi or Arduino and everything's contained to the PCB/perboard.. I don't plan on doing anything extremely complicated (at least not at first); just little LED doodads for now. Obviously. I have no idea where to start really and wonder if y'all could suggest some resources.

Unperson_47 fucked around with this message at 23:10 on Apr 25, 2022

cruft
Oct 25, 2007

Unperson_47 posted:

I think I want to get into learning how to program microprocessors to make standalone PCBs for little electronic projects and stuff so I don't have to use a RaspberryPi or Arduino and everything's contained to the PCB/perboard.. I don't plan on doing anything extremely complicated at first, obviously. I have no idea where to start really and wonder if y'all could suggest some resources.

I am now solidly in camp MicroPython.

Go get yourself an Adafruit Qt Py and go hog wild. That SAMD21 is a hell of a chip. When you've grown out of MicroPython, you can move to C++ and stay on the same board. And the embedded I2C bus connector (Stemma / Qwiic) is just :kiss:

Unperson_47
Oct 14, 2007



cruft posted:

I am now solidly in camp MicroPython.

Go get yourself an Adafruit Qt Py and go hog wild. That SAMD21 is a hell of a chip. When you've grown out of MicroPython, you can move to C++ and stay on the same board. And the embedded I2C bus connector (Stemma / Qwiik) is just :kiss:

Holy poo poo, this might be a perfect first step as I have pretty good experience with Python and like using it. Never even occurred to me that there'd be flavor of it for microprocessors. Thank you!

Unperson_47 fucked around with this message at 23:17 on Apr 25, 2022

cruft
Oct 25, 2007

Unperson_47 posted:

Holy poo poo, this might be a perfect first step as I have pretty good experience with Python. Thank you!

LOL, it's funny, I was just about to edit my post because I had missed that you were already using Arduinos. The Qt Py is a grown up and shrunk down Arduino that can also run Python (and drive an I2S device... and has capacative touch sensors... and a 10-bit DAC... and and and).

But I'm glad my mistake was exactly what you were asking for :)

Unperson_47
Oct 14, 2007



cruft posted:

LOL, it's funny, I was just about to edit my post because I had missed that you were already using Arduinos. The Qt Py is a grown up and shrunk down Arduino that can also run Python (and drive an I2S device... and has capacative touch sensors... and a 10-bit DAC... and and and).

But I'm glad my mistake was exactly what you were asking for :)

Yeah I made a typo myself (or really just used the wrong word) and meant to say I was looking to start programming microchips, not microcontrollers.

I was mostly just looking for something of a way smaller form factor really. Everything I do is just to tinker and play around in my free time and I'm not looking to use the least power possible or anything. It seems like what I'm looking for and I will have a lot of fun with it.


edit: Also I apologize for editing so much. I am bad about typing things before I have my thoughts all together.

Unperson_47 fucked around with this message at 23:37 on Apr 25, 2022

cruft
Oct 25, 2007

Unperson_47 posted:

But if I did eventually decide to toy around with microchips and learning assembly, got any suggestions? I mostly just tinker with stuff in my free time.

Honestly, I'm gonna suggest the SAMD 21 on the Qt Py. It uses an ARM instruction set that, should you for some crazy reason decide assembly programming microcontrollers is what you want to do for fun, you'll be able to port to any number of other chips.

But, like, nobody writes assembly any more*. This thing can run servo motors from frickin' Python. There's no point in getting any lower level than C.

* People still write assembly, but it's a way smaller percentage now than it was even 15 years ago. Just use C.

e: as for "microchips", well, there are a whole lot of them and it's been my experience that they are increasingly designed to work with stuff written in C running on a microcontroller. The stuff I'm currently tinkering with uses an I2C bus that you just link in a library, connect four wires, and you're off to the races. My dad made clever circuits with 555 timers and decade counters. I just write for loops.

cruft fucked around with this message at 23:41 on Apr 25, 2022

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
A modern microcontroller will at least run C.

BattleMaster
Aug 14, 2000

Unperson_47 posted:

Yeah I made a typo myself (or really just used the wrong word) and meant to say I was looking to start programming microchips, not microcontrollers.

I was mostly just looking for something of a way smaller form factor really. Everything I do is just to tinker and play around in my free time and I'm not looking to use the least power possible or anything. It seems like what I'm looking for and I will have a lot of fun with it.


edit: Also I apologize for editing so much. I am bad about typing things before I have my thoughts all together.

Not correcting you to be a jerk but because it may help you find information you need - you mean microcontrollers, which are single-chip programmable computers that are used for control and interface applications.

Coincidentally there is a company named Microchip that makes the most popular lines of microcontrollers!

Unperson_47
Oct 14, 2007



BattleMaster posted:

Not correcting you to be a jerk but because it may help you find information you need - you mean microcontrollers, which are single-chip programmable computers that are used for control and interface applications.

Coincidentally there is a company named Microchip that makes the most popular lines of microcontrollers!

No need to worry about coming across as a jerk if I'm saying something that is wrong or I'm confused about something. Doesn't bother me at all if I learn something.

(also you did not come across negatively)

Unperson_47 fucked around with this message at 00:28 on Apr 26, 2022

Shame Boy
Mar 2, 2010

Honestly if you're already used to the Arduino maybe start with the chip most Arduinos use, the ATMega328P. That's what I did anyway, and since so many people started with Arduino the same way you did there's a bunch of resources out there already about how to make the jump. Plus it's one of the chips you can still get in DIP form if you're not comfortable working with surface mount stuff yet.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
Yeah the ATmega328p is nice, and you can just pop it off of the arduino. The easiest way to program it when its not on an arduino board is by getting a TLS866II Plus programmer from amazon and the XGpro software for it. You will also need to learn how to set up a crystal oscillator circuit for it, and learn how to set the fuses for programming it. But the ATmega328p is really popular and there are all kinds of tutorials and wizards for setting it up. It requires a lot of learning though but I've had a lot of fun looking through the datasheet which is really long to see what it can do. Plus the datasheet as a bunch of example code for things.

Dominoes
Sep 20, 2007

Cortex-M programmed in Rust - do it!

Foxfire_
Nov 8, 2010

Unperson_47 posted:

I think I want to get into learning how to program microprocessors to make standalone PCBs for little electronic projects and stuff so I don't have to use a RaspberryPi or Arduino and everything's contained to the PCB/perboard.. I don't plan on doing anything extremely complicated (at least not at first); just little LED doodads for now. Obviously. I have no idea where to start really and wonder if y'all could suggest some resources.

More high level:

The way a typical simple microprocessor works, there's a CPU core plus flash memory, some RAM, and a whole mess of peripheral devices, all inside the same chip. All of the stuff is internally connected to the CPU so that reading/writing various addresses goes to one of those devices. General computation code is not very different from what you'd write for Arduino stuff, most of the differences are in peripherals.

The microprocessor reference manual will describe all the peripherals in the chip, what addresses their registers are mapped onto, and what the various register bits do. For example, here's a simple register from the GPIO peripheral in a STM32F7:

when the CPU writes those bits, it configures the mode for the corresponding pin. When you call something like "pinMode(10, OUTPUT)" in Arduino, some Arduino library code is ultimately converting that into a write onto a register like this (except different because it's a different chip/GPIO peripheral design). When using a chip outside of Arduino libraries, you'd either do the write yourself, or use some other library/middleware to do it.

It gets more complicated than writing Arduino code because the Arduino library is making a bunch of simplifying assumptions about what you want to do and what the rest of the PCBA looks like. Doing things yourself, you have more freedom, but you also get responsibility to set up more stuff. For example, libraries for an Arduino Nano will assume a certain external resonator and set up to convert that into a 16MHz CPU frequency. On your own board you could use a faster/slower CPU frequency, but you'd have to do all the peripheral configuration that directly or indirectly relies on that (i.e. the UART peripheral register that controls its baud rate is going to be something like "Baud Rate := CPU clock / <value in this register>", not "program me with the final baud you want" actually probably more complicated since there's likely another clock generation peripheral in between so that it's like "Input clock => IO clock => UART clock")

For starting out, you probably want to use an off-the-shelf eval board or other PCBA where you know the electrical parts are fine, and also use somebody else's startup assembly (there is generally a lot of stuff that happens between "This is the address the CPU starts executing from when you turn on power" and main() for your C program).

One Legged Ninja
Sep 19, 2007
Feared by shoe salesmen. Defeated by chest-high walls.
Fun Shoe

Shame Boy posted:

, the ATMega328P. Plus it's one of the chips you can still get in DIP...

Theoretically. After three months of shipping. For $10+ a piece.

Yay, global shortages!

csammis
Aug 26, 2003

Mental Institution

One Legged Ninja posted:

Theoretically. After three months of shipping. For $10+ a piece.

Yay, global shortages!

This is true for the 328 specifically, but there are still plenty of ATTiny and some lesser-used ATMega parts available. Digikey’s showing a few ATMega variants in DIP in stock this morning.

BattleMaster
Aug 14, 2000

Foxfire_ posted:

More high level:

The way a typical simple microprocessor works, there's a CPU core plus flash memory, some RAM, and a whole mess of peripheral devices, all inside the same chip. All of the stuff is internally connected to the CPU so that reading/writing various addresses goes to one of those devices. General computation code is not very different from what you'd write for Arduino stuff, most of the differences are in peripherals.

Microprocessors are generally just the CPU in a single chip. While sometimes found with varying amounts of I/O peripherals like the serial interface on the 8085, the I/O peripherals on the 80186, or the huge collection of I/O devices found in some modern ones like AMD's Ryzen series, you'll never find the main memory or storage on them because their needs for those are far too great to fit into the package. (Edit: for historical context, "CPUs" used to consist of many chips, like older computers where they would be built out of a big pile of 74 series NAND chips, or several specialized ICs. "Microprocessor" refers to a CPU that fits into a single IC package.)

A microcontroller or system on chip is more like what you described - a single chip with the CPU and some or all of the memory and I/O peripherals on it. I've seen varying definitions of what the demarcation between those two are but it seems like there's something of an agreement that microcontrollers are on the lower end of capabilities and are programmed once for a specific purpose, while systems on chip are higher end and are targeted toward general purpose computing with an operating system, and often have external memory because their memory needs are too great to fit into the package.

An Arduino uses a particular Atmel (now Microchip) microcontroller while something like a Raspberry Pi or a smartphone uses a system on chip.

edit: For people who are interested in building a homebrew system with an actual microprocessor, Zilog still makes a modernized Z80 called the Z84C00 that is available inexpensively. It's based on a CMOS process that has lower power consumption and supports higher clock rates than the original Z80, but is 100% compatible as far as software and pinout.

Compared with other 8-bit microprocessors, the Z80 is very easy to work with. It doesn't need latching or other glue logic in its bus interface and it only needs a single voltage and single-phase clock. Its interfacing is so simple that you can construct a functioning system with just 3 ICs and a clock source - the CPU, a parallel non-volatile memory of some kind, an I/O device (a 74-series tri-state latch will do if you want to blink some LEDs) and an oscillator or even 555 timer. It has such a huge number of CPU registers that you don't need RAM for very simple applications.

BattleMaster fucked around with this message at 16:47 on Apr 26, 2022

Forseti
May 26, 2001
To the lovenasium!

Foxfire_ posted:

More high level:

The way a typical simple microprocessor works, there's a CPU core plus flash memory, some RAM, and a whole mess of peripheral devices, all inside the same chip. All of the stuff is internally connected to the CPU so that reading/writing various addresses goes to one of those devices. General computation code is not very different from what you'd write for Arduino stuff, most of the differences are in peripherals.

The microprocessor reference manual will describe all the peripherals in the chip, what addresses their registers are mapped onto, and what the various register bits do. For example, here's a simple register from the GPIO peripheral in a STM32F7:

when the CPU writes those bits, it configures the mode for the corresponding pin. When you call something like "pinMode(10, OUTPUT)" in Arduino, some Arduino library code is ultimately converting that into a write onto a register like this (except different because it's a different chip/GPIO peripheral design). When using a chip outside of Arduino libraries, you'd either do the write yourself, or use some other library/middleware to do it.

It gets more complicated than writing Arduino code because the Arduino library is making a bunch of simplifying assumptions about what you want to do and what the rest of the PCBA looks like. Doing things yourself, you have more freedom, but you also get responsibility to set up more stuff. For example, libraries for an Arduino Nano will assume a certain external resonator and set up to convert that into a 16MHz CPU frequency. On your own board you could use a faster/slower CPU frequency, but you'd have to do all the peripheral configuration that directly or indirectly relies on that (i.e. the UART peripheral register that controls its baud rate is going to be something like "Baud Rate := CPU clock / <value in this register>", not "program me with the final baud you want" actually probably more complicated since there's likely another clock generation peripheral in between so that it's like "Input clock => IO clock => UART clock")

For starting out, you probably want to use an off-the-shelf eval board or other PCBA where you know the electrical parts are fine, and also use somebody else's startup assembly (there is generally a lot of stuff that happens between "This is the address the CPU starts executing from when you turn on power" and main() for your C program).

This is great advice, and I'd also add if you feel up to it, an Altair 8080 emulator can teach you a lot about the architecture of a simple PC too. It has no BIOS or storage (standard, I'm sure people modded them in), meaning you have to enter the bootstrap code manually via the switches on the front panel (emulator will let you click on a virtual front panel). It sounds and is tedious, but you'll learn what the BIOS (or in ARM boards, the device tree/bootloader) does for you because you're the BIOS.

Not sure how most people used the Altair back in the day, but I know there are simple bootstrap routines to get it to load the rest from serial/punch card/disk.

If you REALLY wanna be a homie, you can get yourself a https://www.thebyteattic.com/p/cerberus-2080.html and post all about it so I can live vicariously though you :D

Also hi electronics thread, been MIA for a while, but for pleasant reasons! I have an actual job doing this poo poo again and am loving it. Even though I'm a CS major, the embedded world is soooooooo much more fun to me than web development where they think frontend skills means you know what React libraries to include.

Right now I'm just working on a PoS project, but still get to use an iMX.6 so it's still better than webdev. But in the future, the guy I'm working with and I will probably get to do really cool stuff like ultrasonic medical imaging (he's an acoustical engineer). Super stoked!

Pham Nuwen
Oct 30, 2010



Speaking of Arduinos, what's the smallest option for a USB-capable microcontroller board I can program using the Arduino tools? I've got a USB HID device built around a PIC and I kind of hate the Microchip tools... if I could find something just a tiny bit smaller than the Pro Micro, it would be perfect.

Shame Boy
Mar 2, 2010

Pham Nuwen posted:

Speaking of Arduinos, what's the smallest option for a USB-capable microcontroller board I can program using the Arduino tools? I've got a USB HID device built around a PIC and I kind of hate the Microchip tools... if I could find something just a tiny bit smaller than the Pro Micro, it would be perfect.

There's this thing, but it's so small it's kinda getting into the "not all that useful" territory:

https://mellbell.cc/products/pico

Pham Nuwen
Oct 30, 2010



Shame Boy posted:

There's this thing, but it's so small it's kinda getting into the "not all that useful" territory:

https://mellbell.cc/products/pico

Perfect size but way too goddamn expensive. I suppose I could just put an ATmega32U4 on the board directly along with the handful of support components it needs, but at a quick look the drat things aren't in stock anywhere. I'll say this about the PIC, at least you can buy them right now for like $2 each.

Forseti
May 26, 2001
To the lovenasium!

Pham Nuwen posted:

Speaking of Arduinos, what's the smallest option for a USB-capable microcontroller board I can program using the Arduino tools? I've got a USB HID device built around a PIC and I kind of hate the Microchip tools... if I could find something just a tiny bit smaller than the Pro Micro, it would be perfect.

Are you seeking an actual hardware USB implementation? Because there's V-USB that'll do it on very low spec MCUs (e.g. the Atmega in an arduino) in software: https://www.obdev.at/products/vusb/index.html

Slanderer
May 6, 2007
Does anyone know what the easier way to quickly cut a few D-shaped holes in enclosure panels (for mounting potentiomers). Are there affordable off the shelf punches, or is milling the best bet?

Alternatively, has anyone seen washers that allow you to mount D-shaped items in round holes (while also interfacing with a side hole or slot to keep from rotating). A forum post I read mentioned them and I vaguely recall seeing them once, but I don't have the faintest idea what they'd be called.


edit: ok I guess they're called knockout punch sets? but they're kinda expensive

Slanderer fucked around with this message at 23:34 on Apr 26, 2022

cruft
Oct 25, 2007

Pham Nuwen posted:

Speaking of Arduinos, what's the smallest option for a USB-capable microcontroller board I can program using the Arduino tools? I've got a USB HID device built around a PIC and I kind of hate the Microchip tools... if I could find something just a tiny bit smaller than the Pro Micro, it would be perfect.

Brother, have you heard the good news about the Adafruit Qt Py?

E: oh, too expensive. What about the DigiSpark?

CopperHound
Feb 14, 2012

cruft posted:

E: oh, too expensive. What about the DigiSpark?
I thought I dug deep into the atiny85, but I had no idea you could program it directly from USB.

Stack Machine
Mar 6, 2016

I can see through time!
Fun Shoe

BattleMaster posted:

edit: For people who are interested in building a homebrew system with an actual microprocessor, Zilog still makes a modernized Z80 called the Z84C00 that is available inexpensively. It's based on a CMOS process that has lower power consumption and supports higher clock rates than the original Z80, but is 100% compatible as far as software and pinout.

Importantly the CMOS Z80 also runs at lower clock rates than the original. You'll see "fully static" in the datasheets for a lot of these CMOS versions of obsolete CPUs, including the 65c02, 80C88 and the NEC V20, and it means you can clock it at any rate you want up to the specified max. Most of the O.G. CPUs in NMOS processes used dynamic logic and had minimum clock rates as well, which was hell for hobby projects because you couldn't just stop the system clock and single-step it while you moved a logic probe around, so instead you had to use expensive test equipment for basic debugging.

One of my hobbies is running old CPUs on a breadboard with a big shift-register-based I/O expander connected to a host PC that emulates the memory and peripherals, but this setup can only clock them up to a few kHz, and I have to look for static CMOS designs for this to be practical. One of my biggest failures with this setup was getting a Hitachi 6309 wired up and getting software ready only to find out when it was behaving strangely that despite being a CMOS design, it wasn't a fully static design and had a minimum clock rate of 1MHz.

E: I guess it's bad to post about a hobby like this without posting images of the depravity:


The 80c88 in the breadboard; the ICs at the top are all tri-statable shift registers, so the whole thing works as 64 bits of bi-directional I/O, controlled by a parallel port.


The program running on the CPU, the memory image after it finished, a zoomed-out waveform and the waveform of startup. The software writes .vcd files as it runs. The instruction at address 0x83 is a divide and it takes a long time to run on the 80c88.


The pin-compatible but 80186-based NEC V-20 on the same breadboard.


I ran the same software on this one but the code in the screenshot here is the assembly language startup routine that sets the stack pointer and jumps to the start of the main function. A cool thing about these waveforms is that you can see the same division instruction at address 0x83 (the address lines stay at that value because after instruction fetch divide doesn't access any other memory locations) takes far fewer clock cycles on this otherwise very similar CPU.

Stack Machine fucked around with this message at 04:10 on Apr 27, 2022

VelociBacon
Dec 8, 2009

I've wired 3 Mysa 'smart' line voltage thermostats (for electric baseboard heaters) and I have one left to do and it's boggling my mind.

It's 1 heater on the thermostat, it's wired single pole, I believe 240v but the neutrals are white (the old thermostat says 240v on it but that could just mean it's rated for either). Two cables into the gang, each carrying a white neutral and a black hot wire (line and load), and the copper ground wire which is well and firmly affixed to the box with the two ends screwcapped. The analog thermostat works. I cannot get the mysa to turn on, have tried reversing the line/load black cables to no avail. I have tried swapping in the other known-good mysa units and they don't turn on either.

This is exactly the setup in my other room where it took a handful of minutes to finish the installation. What could be going on with this?

Stolen from the Mysa instructions, this is how the analog thermostat is wired:



This is how I've wired the Mysa in (the second photo but it's basically the same thing as I understand it):



Yes I've been turning the breaker off as I've been doing this. There is another thermostat on this circuit in the other room that's working great. Is it possible this gang isn't wired such that the two whites aren't actually neutral? Could I have somehow wired the other Mysa into this circuit in such a way as to not allow this one to work (but the analog still works)? I'm super confused. Thanks goons.

VelociBacon fucked around with this message at 03:10 on Apr 27, 2022

csammis
Aug 26, 2003

Mental Institution

VelociBacon posted:

mains wiring question

You should post this question in the Wiring Thread - there some overlap in posters but this thread is largely about hobby electronics and not house wiring.

M_Gargantua
Oct 16, 2006

STOMP'N ON INTO THE POWERLINES

Exciting Lemon

Slanderer posted:

Does anyone know what the easier way to quickly cut a few D-shaped holes in enclosure panels (for mounting potentiomers). Are there affordable off the shelf punches, or is milling the best bet?

Alternatively, has anyone seen washers that allow you to mount D-shaped items in round holes (while also interfacing with a side hole or slot to keep from rotating). A forum post I read mentioned them and I vaguely recall seeing them once, but I don't have the faintest idea what they'd be called.


edit: ok I guess they're called knockout punch sets? but they're kinda expensive

Maybe just design and order a new enclosure front from SendCutSend?

Shame Boy
Mar 2, 2010

M_Gargantua posted:

Maybe just design and order a new enclosure front from SendCutSend?

I use Ponoko but same idea.

Another option I came up with a while back if you have access to a 3D printer is to just drill round holes in the enclosure, then print out like 1-2mm thick plastic bits with the right notch shape for the thing you're mounting, then attach them around the enclosure hole. I just used glue, cuz my application wasn't going to see particularly high torque or anything and the actual nut that clamps the potentiometer in takes up most of the force anyway. It worked a lot better than I expected when I came up with the idea :v:

BattleMaster
Aug 14, 2000

Stack Machine posted:

Importantly the CMOS Z80 also runs at lower clock rates than the original. You'll see "fully static" in the datasheets for a lot of these CMOS versions of obsolete CPUs, including the 65c02, 80C88 and the NEC V20, and it means you can clock it at any rate you want up to the specified max. Most of the O.G. CPUs in NMOS processes used dynamic logic and had minimum clock rates as well, which was hell for hobby projects because you couldn't just stop the system clock and single-step it while you moved a logic probe around, so instead you had to use expensive test equipment for basic debugging.

One of my hobbies is running old CPUs on a breadboard with a big shift-register-based I/O expander connected to a host PC that emulates the memory and peripherals, but this setup can only clock them up to a few kHz, and I have to look for static CMOS designs for this to be practical. One of my biggest failures with this setup was getting a Hitachi 6309 wired up and getting software ready only to find out when it was behaving strangely that despite being a CMOS design, it wasn't a fully static design and had a minimum clock rate of 1MHz.

E: I guess it's bad to post about a hobby like this without posting images of the depravity:


The 80c88 in the breadboard; the ICs at the top are all tri-statable shift registers, so the whole thing works as 64 bits of bi-directional I/O, controlled by a parallel port.


The program running on the CPU, the memory image after it finished, a zoomed-out waveform and the waveform of startup. The software writes .vcd files as it runs. The instruction at address 0x83 is a divide and it takes a long time to run on the 80c88.


The pin-compatible but 80186-based NEC V-20 on the same breadboard.


I ran the same software on this one but the code in the screenshot here is the assembly language startup routine that sets the stack pointer and jumps to the start of the main function. A cool thing about these waveforms is that you can see the same division instruction at address 0x83 (the address lines stay at that value because after instruction fetch divide doesn't access any other memory locations) takes far fewer clock cycles on this otherwise very similar CPU.

So I didn't know about the minimum clock rate thing since the NMOS versions of these things were before my time, but that's pretty cool.

Did you build the interface board or is it an off the shelf thing?

VelociBacon
Dec 8, 2009

csammis posted:

You should post this question in the Wiring Thread - there some overlap in posters but this thread is largely about hobby electronics and not house wiring.

Sorry, wrong bookmark! I'll move it over there.

Stack Machine
Mar 6, 2016

I can see through time!
Fun Shoe

BattleMaster posted:

So I didn't know about the minimum clock rate thing since the NMOS versions of these things were before my time, but that's pretty cool.

Did you build the interface board or is it an off the shelf thing?

It's a custom thing, but it's basically the simplest thing you can use to get enough IOs to talk to an old CPU with a desktop computer. Each of the 6 8-bit ports is just a pair of shift registers; a 74hc4094 for the outputs and a 74hc597 for the inputs, with an extra 74hc4094 at the end of the string for the output enables. The 74hc4094 output latch strobes are all tied together so the outputs all update simultaneously. It's all controlled by a parallel port, but it turns out that USB-parallel cables don't support the low-level parallel port API you need to use it, so I had to buy a PCI-E parallel port card specially for it.

I had this vision when I was designing it of buying parts off the shelf and using this to interface with them and learn about them, but it was kind of obsolete from day 1. It was great for reading and writing old EPROMs and parallel SRAMs and playing with old CPUs, which is all good fun, and it works OK with 5V SPI things, including ADCs and DACs, but for anybody just starting out maybe something like an Arduino and a half dozen SPI I/O expanders is more reasonable.

Shame Boy
Mar 2, 2010

I'm using an RPi for a complex project for the first time now and using the pigpiod thing to manage the GPIO's for reasons and holy crap this is some impressively over-engineered poo poo. It's a client/server thing for pin control, which of course raises the question of how you make pin access fast using a client/server model? Why, make your own virtual machine complete with its own assembly language of course :shepface:

http://abyz.me.uk/rpi/pigpio/pigs.html#Scripts

So now I know how to program Raspberry Pi Pin Specific Virtual Machine Assembly Language, I guess that's some kind of skill

Forseti
May 26, 2001
To the lovenasium!

Shame Boy posted:

I'm using an RPi for a complex project for the first time now and using the pigpiod thing to manage the GPIO's for reasons and holy crap this is some impressively over-engineered poo poo. It's a client/server thing for pin control, which of course raises the question of how you make pin access fast using a client/server model? Why, make your own virtual machine complete with its own assembly language of course :shepface:

http://abyz.me.uk/rpi/pigpio/pigs.html#Scripts

So now I know how to program Raspberry Pi Pin Specific Virtual Machine Assembly Language, I guess that's some kind of skill

You should see their pi-gen (https://github.com/RPi-Distro/pi-gen) project for building custom images lol.

I got tasked with hacking it up to make a custom image for our client and my assessment is that it's a well executed implementation of an insane design

BattleMaster
Aug 14, 2000

Stack Machine posted:

It's a custom thing, but it's basically the simplest thing you can use to get enough IOs to talk to an old CPU with a desktop computer. Each of the 6 8-bit ports is just a pair of shift registers; a 74hc4094 for the outputs and a 74hc597 for the inputs, with an extra 74hc4094 at the end of the string for the output enables. The 74hc4094 output latch strobes are all tied together so the outputs all update simultaneously. It's all controlled by a parallel port, but it turns out that USB-parallel cables don't support the low-level parallel port API you need to use it, so I had to buy a PCI-E parallel port card specially for it.

I had this vision when I was designing it of buying parts off the shelf and using this to interface with them and learn about them, but it was kind of obsolete from day 1. It was great for reading and writing old EPROMs and parallel SRAMs and playing with old CPUs, which is all good fun, and it works OK with 5V SPI things, including ADCs and DACs, but for anybody just starting out maybe something like an Arduino and a half dozen SPI I/O expanders is more reasonable.

I'd be interested in a photo showing the whole thing. Do you have all the shift registers in a big chain or do you have each one connected to a different parallel port pin?

I think I have everything needed to whack one together just laying around and I figured I may as well have a go.

I noticed that USB "parallel ports" are just single-purpose devices that act as a USB printer and are only for bridging the gap between a parallel port printer and a system with no parallel port. I was very disappointed when I bought one and found this out. I guess that's the use case of most people who would want one but it still sucks.

At least the several PCIe parallel port cards I've tried out don't pull any tricks like that. They have highly variable build quality and some of them are implemented in really janky ways, like one that I have which shows up as a serial port (and fortunately has Linux drivers which make it work properly), but I haven't yet run into one that doesn't work as an actually honest to goodness parallel port.

Shame Boy posted:

I'm using an RPi for a complex project for the first time now and using the pigpiod thing to manage the GPIO's for reasons and holy crap this is some impressively over-engineered poo poo. It's a client/server thing for pin control, which of course raises the question of how you make pin access fast using a client/server model? Why, make your own virtual machine complete with its own assembly language of course :shepface:

http://abyz.me.uk/rpi/pigpio/pigs.html#Scripts

So now I know how to program Raspberry Pi Pin Specific Virtual Machine Assembly Language, I guess that's some kind of skill

And I, apparently an absolute fool and simpleton, would just install the Preempt-RT kernel patch and run my program at maximum priority

BattleMaster fucked around with this message at 04:57 on Apr 30, 2022

Forseti
May 26, 2001
To the lovenasium!

BattleMaster posted:

And I, apparently an absolute fool and simpleton, would just install the Preempt-RT kernel patch and run my program at maximum priority

I've never used Preempt-RT, but I did think to myself many times how what we're doing could easily be done with the ESP32 and FreeRTOS. And, in my opinion, how much nicer FreeRTOS is to use vs screwing around with Python and Java for an embedded app

Or just run our application instead of init when Linux boots

Stack Machine
Mar 6, 2016

I can see through time!
Fun Shoe

BattleMaster posted:

I'd be interested in a photo showing the whole thing. Do you have all the shift registers in a big chain or do you have each one connected to a different parallel port pin?

The whole thing looks like this. There's 2 serial strings of shift registers on the port, one for all the output ports (E: including the output enables; they're at the end of the string) and one for all the input ports. The USB connector is for 5V power. I have thought about dropping an MCP2221 or similar on there to get rid of the parallel port:



At the risk of doxxing myself, there's a git repo. be warned, there's a lot of :words: but no schematics. All of the layout, design, LVS, etc is done as software written in C++.

https://github.com/cdkersey/busyboard

The, um, thing that stands in for the schematic is here:

https://github.com/cdkersey/busyboard/blob/master/netlist/netlist_gen.cpp

It looks like complete noise, probably, but in my defense the board worked 100% on the first spin and I was able to simulate its behavior.

The host software (for Linux) is also in there with the CPU examples but it's missing a way to generate software for the CPUs. If you're super-interested I can dig up the tools I used for that too.

PM me if you want me to ship you an unpopulated PCB. I think I have a few on a shelf somewhere.

Stack Machine fucked around with this message at 14:25 on Apr 30, 2022

Adbot
ADBOT LOVES YOU

cruft
Oct 25, 2007

Trying to design a PCB in KiCad. I have an SOIC-20 part (at42qt2120-su) that I need to place. It's not in the library, but the TSSOP version is. Any advice on how I can hack the TSSOP part into a custom SOIC one?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply