Previous thread:>>xxxxxxxHere we discuss microcontrollers (MCUs), single board computers (SBCs), and their accessories, such as Atmel mega and tiny AVRs (Arduinos), PICs, ARM boards such as blue/black pill STM32, ESP8266/32s, RP2040, Raspberry Pi, and others.For general electronics questions (power supplies, level shifting, motor driving, etc.) please ask /ohm/.>where can I find verified quality microcontrollers and other electronic sensors or partsdigikey.commouser.comarrow.comnewark.com>but that's too expensivealiexpress.com (many parts here are fake, particularly specific parts out of stock in the above sites)lcsc.com>I need a part that does X and Y, with Z specifications. How can I find it?use DigiKey's or Octopart's parametric part search. Then purchase from one of the sellers listed above.>how do I get started with microcontrollers, where should I start?There is no defined starting point, grab a book and start reading or buy an arduino off ebay/amazon and start messing around. There are a plethora of examples online to get started.>resources:https://github.com/kitspace/awesome-electronics>RISC-V microcontroller list:https://codeberg.org/20-100/Awesome_RISC-V/raw/branch/master/RISC-V_MCU_development_boards.pdf
actual previous thread: >>2774325
no interest anymore?
>>2803735I am interested but I am busy with a move, but I still lurk
>>2803735No. I quit embedded and took up gardening. I now think of snails as Arduino users. The day of the rake is coming for you.
>>2803735The autistic shithead brigade ruined this general long ago.
>>2803735I successfully managed to avoid putting a microcontroller in my last two projects. Used relay logic for one, and an LM3914 in the other. Started work back on a BLDC driver though, I’ll need to mess around with 32-bit MCUs for the first time to get that working, so I’ll post about that in a month or so.At least we can keep the thread bumped with arduino hatred.
>>2802510I need to run 4 arduino input / output wires 50 yards. 5V going through them max, need no signal loss. Using CAT6 Ethernet cable atm. What are my other options?> waterproof> no signal loss without repeater bullshit> can be rolled up, stepped on, cows might shit on it
>>2804613What kind of current draw? If no power is needing to be transferred (i.e. there’s a power source at both ends), I’d want to add differential pair transceivers on each end, with termination resistors to keep the line impedance low. Like RS485 or whatever. That would use up all 8 wires in your cat cable. But if it works as-is then I probably wouldn’t worry about it. Run it through conduit if you want something stronger, or use that double layer insulated outdoor rated cat cable.
Have any of you successfully connected an ESP32 or nrf52840 that is emulating a keyboard to a PS4 console? I keep trying and it tells me it's not supported and then I change the vendor and product IDs and it gets me to pair it before it tells me that it's unsupported. Any advice on libraries or options?
Any of you fucks have experience with using rust (inb4 troon) on an esp32?
>>2804751What does that even mean? You want to compile and edit and run on the esp?If just run compiled, the existence of mrustc—turning your rust code into C—and using that would pretty much solve your problem.Then, once you have the resultant C code, delete the original rust code and maintain it C as you should have in the first place.
>>2804737I bet it doesn't like your report descriptor.And I am not going to help you with it because I haven't touched that shit in years.
>>2802510What’s OPs image? I see the pi, the arm, the sd and the leds plus the nip characters. Some kind of serial interface/led light chaser?Here’s mine latest. Paper speaker, lm386 and some 555s made baby’s first synth today. Worst speaker I ever heard and I cooked one timer trying to pull too much current when the amp didn’t work but it makes lights and sound and there’s only room for improvement.
>>2804871Hooking the fan up in place if that “speaker” would orobably sound better.
>>2804751Why would anyone want to use rust on embedded? I am not saying use C++, just use C
>>2805061Memory safety I guess, but all these examples of managing hardware (which are "singletons" to desktop brain damage programmers) with the retarded Rust ownership model makes me not want to take them seriously.
>>2804905I don’t see how? The pulses that drive the speaker wouldn’t be enough to get the fan going and spinning is not the same as oscillating. I do however have my eye on some audio exciters that should shake things up.
>>2805338No, but the fan doesn’t have to “go” it just has to vibrate and the blades act as the “cone”.This was an actual product from a few years ago, except it was an actual spinning fan that could impart the audio through the fan blades.>>2805086> memory safetyHeh, I see singletons as more of a new name to “global variables” but the cargo cultests follow the “globals are evil” doctrine without understanding how computers work.Embedded and microcontrollers bring you a lot closer to the computer. The C++ and Rust people are out of work theoreticians and neither one ever had any practical value except to be different and sell O’reilley nutshell books. And maybe for dummies books. That’s why they’re constantly adding and changing shit.If you want memory safety, look up MISRA C rules and valgrind. Ultimately, they’re just bugs, and it’s up to you to fix them by whatever means necessary.If you look through he gnu C standard library, like half of it is written in assembly to take advantage of SIMD anyway. Only works with long strings, the setup and checking sometimes takes like 100 clocks, so it’s worthless. Hopefully the compiler can figure out if it’s a “long haul” sized string or can fit in an m_128… oh it can’t? Well, so much for that.I dropped rust when I updated the compiler and it kept crashing. The compiler itself is written in rust. It’s worthless, and it told me so by dumping core.
Is it possible to make a somewhat useful computer with a P8X32A?
>>2805663>I dropped rust when I updated the compiler and it kept crashing.I bet that's because they use LLVM, a C++ project, to do the real work at code generation, and some API or ABI incompatibility got them.
I learned C intending to get into programming some stuff, but ended up using other dev environments instead. Is there much difference between regular C and embedded C, and can I use it on any old microcontroller? I'd love to give some electronics projects a try, since that kind of low level, simple programming looks like fun.
>>2806396theres not really any fundamental differences in syntax. however things like dynamic memory allocation, multithreading/processing, networking are just a few of the things that dont work out of the box on a mcu. instead those features are chip specifc and may use different function names and have other limitations
>>2806449To start with I'll only be doing basic shit like a light controller or a garden watering monitor. Is it possible to use assembly to program mcus as well? >instead those features are chip specifc and may use different function names and have other limitationsI guess as long as the documentation is good I'll be fine.
>>2804828Anon, I will give you the finest PP touch that a straight man can send over text if you at least point me in a direction that isn't "sucks to suck, faggot."
>>2806452Assembly is usually preferred on smaller mcus.You can almost always emit assembly code from your C code. Everything used to work that way until idiots became involved.Even microsoft C++ could do this and you could assemble the output it with masm. Up until 2016 or so, but then they said “the asm might not complie any more” … but the microsoft boat is adrift at sea with no captain and infested with pakleds.If you write it in assembly, and you gave trouble with something, sometimes it’s helpful to “cheat” and see how the compiler emits the code for it. Maybe you want to copy it verbatim, but more likely you can cut it down by two thirds… it’s a little chatty sometimes and does useless checking or saves registers you don’t care about.CISC cpus were more designed to be programmed in assembly, back when they cared about that stuff. RISC CPUs, not so much… this culminated in the Itainium, the ultimate expression of RISC and the futility of the endeavour. Thank god it never made it to the embedded arena but the lesson should be observed from a distance and learned from.
>>2806396Read a microcontroller datasheet to see what you might be getting yourself into. I recommend an older AVR like the popular ATmega328P. It has both assembly and C code examples, though I prefer how the later AVRs handle their I/O ports.The relevant assembly manual may also be useful, if just to see what instructions the part you've chosen has. Whether it can do hardware multiplication or division, floating point, etc. Whether it can bit-shift multiple bits at once, or just one at a time. Whether it has instructions for easily reading longs from adjacent registers, or if it can read-bitwiseop-write a register in a single clock cycle. Additionally, and this may be in a different document, how many clock cycles it takes for things that don't have instructions, like different multiply and divide routines from different optimisation levels. The kind of stuff that's important for optimising code.I'd also check out Ben Heck's videos where he programs an ATtiny10, a chip with 6 pins, 1kB progmem, and 32B RAM, to run space invaders. Surprisingly entertaining.
Hello /MCG/ is there a better, high IQ way to talk to individual pins on a shift register than just to specify every bit digit individually?(I'm too embarrassed to ask chatgpt again)[code]#include <SPI.h>/*Define the pins we are using on the Arduino Board and cross reference them with the pins on the Shift register so you can give them appropriate names*/int latchpin = 3; // chip selectint datapin = 11;int clockpin = 13;byte shiftLED1 = 1;byte shiftLED2 = 2;byte shiftLED3 = 4;byte shiftLED4 = 8;byte shiftLED5 = 16;byte shiftLED6 = 32;byte shiftLED7 = 64;byte shiftLED8 = 128;void setup() { SPI.begin(); //Start the SPI library SPI.setBitOrder(MSBFIRST); //Set LSB as bit order, this means we will send the least significant bit first and it will be written to Q7 = Register Pin 7 with the most significant bit being written last to Q0 or Pin 15 /*Configure the Arduino pins we use as OUTPUT, so they can send data to the Shift Register */ pinMode(latchpin, OUTPUT); pinMode(datapin, OUTPUT); pinMode(clockpin, OUTPUT); delay(50);}void loop() { digitalWrite(latchpin, LOW); SPI.transfer(shiftLED3); // Send a test byte digitalWrite(latchpin, HIGH); delay(0); // 1 second delay to observe changes digitalWrite(latchpin, LOW); }[/code]
aah how would I even iterate a for loop this way?im brain ded
>>2806527you need a "shadow register"add a variable to keep the state of all your LEDs, turn bits off and on in that, then send it out to the shift register
>>2806527Instead of >byte shiftLED1 = 1;>byte shiftLED2 = 2;>byte shiftLED3 = 4;it's more common to see>byte shiftLED1 = 1<<0;>byte shiftLED2 = 1<<1;>byte shiftLED3 = 1<<2;Of course, you should call them LED0-LED7, not LED1-LED8, for more clarity. I'd also use the term "bitmask" (or "bm") instead of "shift" when labelling these variables.But better than that is to use the bitmasks that come along with the register data in the header files that the compiler uses. I don't actually know where to get human-readable names for these bitmasks, I see them in tutorials and code that MPlab wizards create for people, and in examples in datasheets, but nowhere in whole. They make more sense with status registers, here's an example:>/* Write logical one to WDCE and WDE */>WDTCR |= (1<<WDCE) | (1<<WDE);Where WDCE is bit 4 of the Watchdog Timer Control Register WDTCR, and WDCE stands for Watchdog Change Enable. The actual constant WDCE is just "4", it's intended to be used to bitshift for bitwise boolean setting or unsetting of bits. For I/O ports specifically, here's another example:>/* Define pull-ups and set outputs high */>PORTB = (1<<PB7)|(1<<PB6)|(1<<PB1)|(1<<PB0);>/* Define directions for port pins */>DDRB = (1<<DDB3)|(1<<DDB2)|(1<<DDB1)|(1<<DDB0);Here, writing "PB7" is the same as writing "7", but it's more clear.The arduino IDE uses something similar but more removed from the user and less flexible, it uses a selection of functions to calculate which bitmask of which port a given "i/o pin number" is, e.g. arduino pin 12 = port B, bitmask 0b00000001. It's fine for static use cases as it all gets precalculated at compile time, but if you're trying to iterate through several pins it becomes extra bloat. See:https://forum.arduino.cc/t/get-portx-from-arduino-style-pin-number/469729/8 If you want to optimise code portability (e.g. in a Marlin compiler) then using this sort of function may well be desirable. I don't know how to use it properly.
>>2806539>>2806527also i misread your entire question but i think it's not entirely out of place
>>2806539Ok anon. I didn't really get it. but thanks for your effort anyways.I asked chatgpt where I learned about bitshifting. I feel retarded for having everything spoonfed but I guess I also learned something new:https://pst.moe/paste/gyenln
Getting ready to start a phone alert security project with esp32. Sensors are of the 433mhz sort. I’ll figure out the hardware stuff but I’m confused about the pushing of notifications. Looks like a lot of options. Was going to try and learn MQTT and use mosquito but I’m not sure if that’s the best route.
>>2806539> byte shiftLED2 = 1<<1;Except you shouldn’t make a variable for a constant. I’ve worked with microcontrollers that are 128 bytes of memory and you don’t want to trust the compiler to optimize that out.
>>2806482That's really good to know, I'm kind of hoping to build up enough knowledge to eventually make my own 8-bit microcomputer clone, but first I need to get a grasp of the basics. Having watched the Ben Eater 6502 videos, assembly seems like an interesting way to program.>>2806520I've got a few 328Ps and a 2560 that I need to dust off and put to use, then.>Ben HeckI'll definitely give that a watch, thanks anons.
>>2806785Well I'm pretty sure that will get consistently optimised out, but I can feel some of that apprehension. Is #define the better way to go?
>>2806662Mqtt implies the need of having a server, if you want to keep it simple just set it up to send emails or telegram messages
>>2806530What is your expected result and what do you get instead? The loop condition won't end as the "i" counter isn't ever increased, but instead the test byte (?) "shiftLED".
>>2806530>for (led i = 0; i <= 255; testLED++)should probably be >for (int i = 0; i < 256; i++)Then increase testLED inside the loop, either directly after usage or at the end. If that's even what you want done?
>>2806543>asked chatgptPick up a book or find a bootstrap example. No one sanitize the output of AI and it is frankly rude comining with that crap and asking others to do it for you.
>>2806543>asked chatgptDon't forget to kill yourself, low IQ retard.
>>2806530>delay(0) // 1 second delay to observe changes
>>2806894> use #defineMost certainly. Always use the simplest tool that accomplishes the task.Also, assembly typically uses macros as well, so it’s easier to adapt. I sometimes prototype fluffy things in C and then rip out the assembly code and optimize it.A lot of microprocessors have special instructions that you can sometimes take advantage of.Microsoft’s C++ template system used the C preprocessor to work, which was kind of funny when it was discovered since the C++ theoreticians and neo-purists hated the C preprocessor without realizing #include was just that.
>>2806931Thanks, I’m an aspiring boomer that’s never used telegram either but I’ve already got a new bot so that was pretty easy. What’s my exposure puttying WiFi credentials into the arduino IDE and sending a hello world message from the ESP32? Are the hackers going to come in through my back door?! Any steps I can take or concepts I should explore to protect said back door?
>>2807040>t. born with intrinsic knowledge of everything>shitposts on a Tibetan homesteading forumnice
>>2807201Just don’t hook up your dev env to the internet. Simple.
>>2807207Development environment? Is that the same as arduino IDE because the machine running that is connected to web. Is there a sandbox or something that should be involved? Also what’s the secret to flashing these fucks. I swear I’ve done it before but I’ve got 8266 and 32WROOM and between the two I can’t figure out why the ESP8266WiFilibrary won’t work or if the flash/boot button pulls pin 0 low or how long I’m supposed to do that. At least I keep getting different errors. >t.ignorant, please spoonfeed.
>>2807435> dev env == arduino ideSo, it depends on the microcontroller. For the older architectures, you can get by with an old 386.So what do you have on there?Editors, compilers, debuggers, emulators, eeprom burning stuff, now writes flash instead, telix, serial ports, rs232 to uart box, parallel ports, your pickit2 or whatever. It’s sometimes useful to have a few dev microcontroller dev boards to handle things like i2c, spi, gpio, d/a and a/d converters, or maybe a raspberry pi or latte panda for usb stuff. Or, maybe you want a pentium if you’re doing Usb.
>>2803735its summer in the US, alot of people would rather be outside, than cooped up inside doing electronics.
>>2807482It’s already too hot out.This is peak basement-dweller productivity time.
>>2807444Checked. although took too many neurons to figure out you’re probably suggesting I use an old dedicated machine with no internet connection. If so, good advice and I imagine anything else is beyond my scope. Currently I think my usb cable is charge only because I cut up the other ones to use for powering leds.
>>2802510How do I charge esp32-cam with a lipo battery?
>>2807035>it is frankly rude comining with that crap and asking others to do it for you.Reading back on the post it does sound kinda rude, but wasn't intended to be. I didn't really understand the entirety if Anons post but he led me in the right direction with bitshifts and the code example chatgpt provided was genuinly helpful.
Hi /mcg/Doing my first ever electronics project:a doorbell camera.Saw a video on the esp32-cam and it looked simple enough.Have ordered bits from aliexpress.Wish me luck.
>>2808390>run esp32-cam from lipoFrom https://www.dfrobot.com/product-1879.html>Power supply range: 5VYou could step up your 3.6v lipo to 5v using a step-up/boost circuit.Or step down 7.2v (2 cells) to 5v using a linear regulator.>charge lipoIf 1 cell then maybe tp4056 ?If 2 cells then I don't know.
>>2804737Does it work against your pc ?Here's a video showing an oscilloscope-level view into usb keyboard stuffhttps://www.youtube.com/watch?v=wdgULBpRoXkIt does briefly talk about the usb from 27:58.
>>2808583>It does briefly talk about the usb setup from 27:58.Fixed.
>>2808583I thought the point of that video was to show that PS/2 keyboards and mice were simple and worked well, and USB started off as a disgrace, and went downhill from there.“let’s base the USB supply voltage on TTL logic since that will be around forever and will only become more popular”
>>2808610That must be some other video.He spends the bulk of this video looking at traces and decoding by hand what is being sent between computer and keyboard.
Here's some AI kino that got posted in this SO thread:https://electronics.stackexchange.com/questions/715517/artificial-intelligence-in-pcb-component-definitions
>>2802510>have a need for an analog/digital io block to can bus module for attaching various signals to and making them available on the can>find no products or even projects that do just that>"fine... I'll do it myself">stm32, can bus transciever, 8 channel optoisolator for inputs>find some basic example code off ST's website and strip it down further to build off of>whole thing done in 3 hours>want to expand the project a bit>want to pull in data from a 1-wire bus >one project exists for it>doesnt compile>bullshit OOP issues >get fuckedFINE ILL DO IT MY FUCKING SELF AGAINwhy is everything hard and make me learn how to just solve it myself instead3 year old code on github, load the .ino, put the header file in the right folder, click compile, dozens of undefined reference errors.clearly the code worked at one point, and 3 years later it doesnt. why
>>2809111People like myself, and probably yourself, that are pro-grade, don’t vomit their failures on github, and don’t have time to write books about it either (back when those were a thing)I’ve seen shit on github that’s so bad, I’d have sworn they were planted by our competitors to fuck us up. You can even find stuff that basically implements security holes and could damage d to a attached equipment, like all lines locking-up hi simultaneously due to bugs when they try and bit bash a 3ph motor signal.Of course, this cesspool of github detritus is what a lot of the code-writing AI feeds from. Might as well have someone from india do it.
>>2808583Yep, it works perfectly on PC. But I know that the PS4 only supports a few Bluetooth keyboards. My goal is to figure out a way to spoof one of those keyboards.
>>2809118But they have working examples in videos and they are white American. I think it is a case where the code works on their machine or worked 3 years agoIt's only a few hundred lines of code anyway so I can just simplify it and de-oop it until it works perfectly as all things do. It just doesn't help that I'm low int on c++
>>2809126> low int on c++I’m high int, I started decades ago on cfront.After too many decades, I realized that oop and c++ is bullshit, and is made worse with every new c++ misfeature that out-of-work theoreticians put forth because they’re academic and not practitioners (who are too busy getting things done). There’s a few neat tricks and whatnot in c++ over C, but nothing very extraordinary.Could be worse though… python comes to mind.> de-oopGood. You’re ahead of the game.
>>2809119> ps4 bluetooth keyboardsI find that all kinds of devices randomly support/or don’t work at all on random bluetooth keyboards.Some can’t even see them to pair. But it’s random, across apple, PCs, laptops, PS3/4, etc, and all kinds of bluetooth keyboards both big names and chiwanese knock offs.The worst thing is when you have to go dig out the original controller to use that stupid pad thing in one random place where sony paid-off the game devs just to include it somewhere in the game to make it artificially relevant.
>>2809111>.inothere's your problemassuming your stm32 actually has hardware 1-wire support, it should be pretty easy to just read/write the registers in the right order and shuffle data like any other comms hardwareif not, you can bit-bang better than a tarduino
Give it to me straight bros: what's the minimum voltage you can run a Arduino Nano at? ESP2866? Surely you can run it on a single button cell? All I get is "but you wouldn't do that, you would run it of AAs"
>>2809189read the datasheet
>>2809184It might have some hardware, but I'm using it for hardware can supportIt just level shifts to 3.3v and goes in an pin.I don't have to transmit so I can really strip it down
>>2808557You’ll need more patience than luck. Following a video is almost retard proof just don’t get mad when you start coming to terms with how retarded you are, like most things it will be an opportunity to be less retarded. I believe in you Anon.
are there any cheap FPGA dev boards like the icesugar line, but that actually have a serdes?
>>2802510Will I be able to play a 4gb .mp4 video file even though the pi 3 B has 1gb of ram? I need to convert a raspberry pi 3 B into a media player, with composite video/audio coming out of the 3.5mm jack. I have an understanding on how to configure the 3.5mm jack, but I also need a script to have the device launch a running media player app upon startup. Can I get some help on where to go to find a script like this, or where to find a how-to for a project like this? Big thanks in advance for any help you can provide. I'm hoping to have this running by Saturday for a video art installation.
>>2809493>Will I be able to play a 4gb .mp4 video file even though the pi 3 B has 1gb of ram?Sounds fine.Bits of the .mp4 will be read from usb drive as they are needed.>need a script to have the device launch a running media player app upon startup.(1) install raspberry os to sd card(2) confirm install by booting your raspberry pi from the card(3) poke around the desktop and see if you can get it to play your .mp4 file at all(4) poke arounds settings to see if you can boot without login or password straight to desktop(5) poke around settings to see if you can get it to launch a program as soon as you login, eg: a web browser
>>2809501I found an install (Video Looper) but I can't get config.txt settled so the pi outputs a working NTSC 4:3 signal. I tried sdtv_mode=0 and sdtv_mode=16, and neither are working. The config.txt also said to uncomment the sdtv section for PAL. I commented the section and no clear picture. The pi boots up and my tv displays a messed up NTSC signal. Any ideas? I'm using a 3.5mm headphone jack RCA splitter and I have the composite cable plugged into the correct jack port.
>>2809536I think I figured it out. My 3.5mm RCA adapter isn't the right style for a raspberry pi.
>>2809493>also need a script to have the device launch a running media playeryou can install an OS that contains just a media playerbest is LibreElec, second best is OSMC(or OMXPlayer if you prefer a geeky command-line experience)https://www.youtube.com/watch?v=ngGkVd-_LP8
>>2809493>Will I be able to play a 4gb .mp4 video file even though the pi 3 B has 1gb of ram?The total size of the video doesn't matter shit, because it will be streamed from the storage media. What matters is how the video file is encoded (resolution, codec profile), and how the player manages memory.
>>2809493Every media format since caveman times has been readable incrementally, instead of having to load the entire thing in ram. The rest is up to how your media player handles things, it should be fine if it’s not potato coded.
>>2809961> potato codedReading everything into memory has been commonplace among the retards that infiltrated 90% of sw devs for the last 15 years at least.
>>2810000checked quads of truth
>>2809493>that picWhat is this thing? Tried various terms in google and I can't find anything like it.
>>2810388https://youtu.be/pbpFgvttBZw
>>2810388>he doesn't know about eurorack synths
And idea what I'm missing here. I'm expecting TX to idle high, but it's not. (SAMD21E18A). Pullups? idk..void UART_init(void){ uint32_t u32_baud = 36000; // Configure pins IO_pin_gpio_init(IO_PIN_PA24); // init TX IO_pin_gpio_init(IO_PIN_PA25); // init RX IO_pin_pmux_enable(IO_PIN_PA24, IO_PERIPHERAL_FUNCTION_C); // Enable peripheral function for pin TX IO_pin_pmux_enable(IO_PIN_PA25, IO_PERIPHERAL_FUNCTION_C); // Enable peripheral function for pin RX // Enable the peripheral bus for SERCOM3 PM_REGS->PM_APBCMASK |= PM_APBCMASK_SERCOM3(1); // Use GCLK 0 to clock SERCOM 3 GCLK_REGS->GCLK_CLKCTRL = GCLK_CLKCTRL_GEN(GCLK_CLKCTRL_GEN_GCLK0_Val) | GCLK_CLKCTRL_ID(GCLK_CLKCTRL_ID_SERCOM3_CORE_Val) | GCLK_CLKCTRL_CLKEN(1); SERCOM3_REGS->USART_INT.SERCOM_CTRLA = SERCOM_USART_INT_CTRLA_MODE(SERCOM_USART_INT_CTRLA_MODE_USART_INT_CLK_Val) | // Use internal clock SERCOM_USART_INT_CTRLA_CMODE(SERCOM_USART_INT_CTRLA_CMODE_ASYNC_Val) | // Async mode SERCOM_USART_INT_CTRLA_DORD(SERCOM_USART_INT_CTRLA_DORD_LSB_Val) | // Send LSB SERCOM_USART_INT_CTRLA_RXPO(SERCOM_USART_INT_CTRLA_RXPO_PAD3_Val) | // Pad 3 for RX SERCOM_USART_INT_CTRLA_TXPO(SERCOM_USART_INT_CTRLA_TXPO_PAD2_Val); // Pad 2 for TX SERCOM3_REGS->USART_INT.SERCOM_CTRLB = SERCOM_USART_INT_CTRLB_SBMODE(SERCOM_USART_INT_CTRLB_SBMODE_1_BIT_Val) | // Single stop bit SERCOM_USART_INT_CTRLB_RXEN(1) | // Enable RX SERCOM_USART_INT_CTRLB_TXEN(1) | // Enable TX SERCOM_USART_INT_CTRLB_CHSIZE(SERCOM_USART_INT_CTRLB_CHSIZE_8_BIT_Val); // 8 bit char size SERCOM3_REGS->USART_INT.SERCOM_INTENSET = SERCOM_USART_INT_INTENCLR_TXC(1) | SERCOM_USART_INT_INTENCLR_DRE(1); SERCOM3_REGS->USART_INT.SERCOM_BAUD = u32_baud; SERCOM3_REGS->USART_INT.SERCOM_CTRLA |= SERCOM_USART_INT_CTRLA_ENABLE(1);}
>>2810757> uint32_t u32_baud = 36000;> SERCOM3_REGS->USART_INT.SERCOM_BAUD = u32_baud;Why is this a variable?
>>2810898It makes it easier to track in gdb, you pedantic twat
What is the cheapest SBC out there that can hold "full" linux (kernel + some networking)?Raspberry Pi Zero 2 W is $15, but can we find something for below $5? Specs can be worse.
>>2810945> linuxThe real goal should be running something like bsd 2.11.
>>2811006To be honest, linux is not a hard requirement, as long as it has networking stack and can communicate with ethernet camera
>>2810757do you have a device connected to it or are the rx/tx lines floating? im pretty sure the "idle high" is actually done by the receiving end not the transmitting end.
>>2811125I have them being passed through my debugger. TX lines are typically pulled up by the transmitter. Receiving devices expect their RX line to be pulled up by the transmitter. Could also be the case that there's some peripheral muxing problem. Not sure. Will take another crack at it tomorrow. Let me know if anything comes to mind
>>2810945>What is the cheapest SBC out there that can hold "full" linux (kernel + some networking)?>Specs can be worseYou phrased that a bit retarded. What's your tasks/requirements? What are you trying to accomplish?Is it for personal education? => Better buy popular board, you'll get more options later.Is it one board only project? Can you (re)use old board? => Buy a used router (check OpenWRT support though).Why do need GNU/Linux at all? You can use networking on more simple OSes. => STM32, ESP32 etc support networking almost natively
Programmer here, not new to microcontrollers but don't have a lot of domain knowledge.>friend has idea for product>pick up Xaio ESP32-C6 to prototype it>oldered on a battery>blink program killed it in a few hours>want to start experimenting with the deep sleep mode to try and squeeze more life out of it>need visibility into the battery stateI know I can basically read the battery voltage as a close approximation of battery life, but all my searches have returned no results on how to do this or if there's a nice battery info package.I know some of these pins are analog, so is it as simple as just reading one of the analog pins with nothing connected to it to get the voltage and doing some math, or is there some electrical concept (voltage drop? idk) that makes that flawed? What is the proper google search terminology to figure this out?
whats the easiest, least bullshit way to add a ntc thermister to a stm32?any simple built in functions or some simple code I can use? I dont want to use some bloated 3 file 1200 line abortion to read the fucking outside temp, especially when it gets condensed down to the same damn fucking shit in machine code no matter how autistic you write it
>>2811382If you don't want to use shitty third party code written by idiots (like most "driver" code in embedded seems to be), you need to do it yourself. First get the shitty third party code to work to make sure the hardware works. Then either write your own code by reading the datasheets, or minimize the third party code by removing all bullshit.
>>2811351Okay I figured out how to do this I'm just reading A0 and doing some math, but I am unable to upload sketches while connected to both battery power and USB power. If I disconnect the battery, it works, if I unplug it then reconnect my battery, the sketch works.Anybody know why this might be?
>>2811405I think i figured it out already>buy TPM36>analogRead(pin)
>>2811415>voltage linear to temperatureI guess that works, if your ADC is good enough.>Ardushitto APIDie.
>>281141812 bit adc, it's temperature, it does not matter.>ardushittoNigger it's a stm32All I am doing is getting the pin value to however many decimal places, and sending that value over can bus.
>>2811421analogRead is Arduino convention. I thought maybe they ported it to stm32. Most C devs would probably prefer this_convention.
>>2811425I'm sure there's some other method like HAL_Get_Pin or something like that but I just don't care, I already do digitalRead for other functions and it just werks
>>2811421>>ardushitto>Nigger it's a stm32"Wiring", "Processing" and other arduino-like APIs are not confined to the AVR chips
>>2811406posting a schematic of how youve wired it up might help for a start
>>2811351Battery capacity voltage/capacity curves are very non-linear and differ by chemistry, size, etc. On top of that, you can discharge a battery less (i.e., set your "0%" to a higher voltage) to get more lifetime charge/discharge cycles out of it. In most consumer devices 0% is definitely not 0% on the cell.The easiest thing for you to do software wise is add a discrete fuel gauge IC. It will do the compensation, filtering, measurement, etc. that you need. Do a search for "fuel gauge," pick your flavor, TI, analog devices, etc. Follow integration manuals for those components because measuring voltage affects the voltage, which affects the curve, which affects the measurement, etc. If your MCU is running and you really care about battery life, that means there is a load on the cell that will affect the voltage you're trying to measure. A discrete IC gets around this.You may also want to look into cell characterization, that's the process by which you work out those curves for your particular cell/load. If you are doing a production part you'll want to do some testing to figure out how to squeeze the battery life you want out of the power budget you have.
>>2811351>>2811611(2/2)As for software, different peripherals of your MCU will have different current draws; if the datasheet is good they will tell you. But in general, you want the MCU to be in the deepest sleep it can be while preserving the state that you need for your application (many can power down SRAM but only partially, for example) Your RTOS also probably has configuration options that will sleep the processor to various degrees when entering the idle task, for example; the tradeoff is that there's some latency to wake back up.Having the CPU running, or a lot of RAM, is expensive power wise. So it's better if you can to do e.g. DMA, or batch sensor reads so that a SPI line can be kept "on" for only a short time, instead of waking it up a bunch of times every time a tiny amount of data comes through. For that ESP, the Wifi and BLE radio are very very power hungry peripherals that you should keep alive as infrequently as you can manage. Techniques like that. And, choose your MCU well. Keep your memory footprint as small as it can be. Not sure about the ESP32 family but MCUs come in various flavors, one of which is usually a "low power" version which is designed with good sleep current draw and fewer power-hungry peripherals.
>>2811406The pixies line up and march from the negative of the battery, through your MCU, to the positive of the battery. Your MCU measures how energetic they are on the positive side by having them flow from ground into a capacitor inside the MCU and then timing how long it takes for the voltage to equalize.So if you connect a USB, your MCU starts drawing power from that, and the pixies don't really know where to go. Why would they go towards the cell when they can just go towards the higher-voltage USB port instead?That's why it works only one way.
I'm logging data to a csv files on an sd card (esp32c3 sdspi), do I have to worry about synching the fat filesystem or at least blocking the main loop if the 5V starts to sag?
>>2811751esp32s are a 3.3V device so it hardly matters. why would your 5V line "sag"?
>>2811806Because I'm unplugging it to turn it off.
>>2811807Don't do that
>>2811807well thats fine when you are not dealing with external memories or internal flash writes. but since you are, you should explicitly finish all transfers and unmount the memory before turning it off. most actual devices that datalog have a battery backup if the main power source is lost, and it will kick in and allow the device to turn itself off properly
>>2812001I was hoping that a smallish capacitor (500uF) would last long enough to do the File::sync_all(). Another way it can go wrong is if somebody ejects the SD card without powering it down.
what microcontroller (programming) and frameworks/tools/standards should i learn if I want to get into automotive embedded programming?
>>2812541It depends on what you mean by that.MISRA, obviously, for that high level C fluff.The tesla still uses the ‘ol MC68HC11 in places.
i have stm32 blue pill and stlink v2 and i need to program a bios chip and i've tried flashing it with this program to use it for thathttps://github.com/dword1511/stm32-vserprogbut i can't get through with it because my PC doesnt detect /dev/ttyUSBxxx nor /dev/ttyACM etc. i've tried on Xubuntu liveusb and still no luck, my regular install is nixos and my user is in flashrom group the jumper is on 1 on BOOT0 and 0 at BOOT1i am an absolute beginner
>>2812751>beginnerThen you may be interested in knowing that controlling serial lines directly requires some special permissions, at least on Ubuntu. You don't need root, it's just standard Linux shit about adding random lines of text to random config files. That's the way i remeber it at least. Try ithttps://askubuntu.com/questions/58119/changing-permissions-on-serial-port#58122Idk if this is your exact issue>>2812719Misra, rightFanks
having trouble with RPI interrupts:i was on here a while ago asking if a RPI could handle GPIB. i bought a board, installed the drivers, and was able to successfully transmit a message to my oscilloscope. reading from the scope, however, is not working. i send "*IDN?", which asks for the name of the device, and i get back "T" (the first letter of "Tektronix"), but nothing else, and the Pi times-out waiting for EOL. the scope shows the DAV (data available, active low) line going down several times, but the interrupt routine in the kernel module (which gets the interrupt with request_threaded_irq()) is only being called once. im not sure how to proceed. any ideas?>>2802510hey, its my image! thanks for saving it! btw, the LCD says "lolicon".>>2804871its an STM32L462 (or something like that). i bought one and tried to get it to do something just to see if i could (and also to learn how MCUs work under the hood). the reference manual was like 1600 pages long and it took many nights just to get an LCD to blink. the Pi (same one in pic rel!) uses SPI to program it and it uses UART to get output. i got printf() to output over the UART controller, quite proud of that one. the LCD is controlled with some hardcoded GPIO stuff. i never got the SD card to work, not for lack of trying.
>>2812771i'm new to electronics, not linuxi can see the stlink device in lsusb but i dont have any interface in /dev/not sure if that's a permission problem because i tried that on root think i've had that same issue with my arduino i dont know, i dont use ubuntu i fucking loathe how not streamline it is, they just change shit for the fuck of it
>>2812772>im not sure how to proceed. any ideas?Get a USB logic analyser (or a second scope) to probe the lines and see if it is sending more letter than just the T, or if it’s waiting for flow control pins or a clock edge or whatever. Compare what you see to a handy timing diagram that I hope someone made already.I did the same logic analyser snooping to figure out that my scope RS232 was actually a master that was to be sent to a plotter, and was carrying HPGL data. For that I used a cheap FX2-based unit.>>2812776Maybe /g/fglt will have some archaic insight for you?
>>2812841>Maybe /g/fglt will have some archaic insight for you?they wonti'm asking here because i wasnt sure if the jumper is set correctly or the device is fucked for some reason or maybe someone's used that program before/g/ is just /v/ with gpus, we don't even discuss linux anymore
>>2812841>Get a USB logic analyserdont have that>(or a second scope)do have that>see if it is sending more letter than just the Tfrom what i can tell, it's sending the T, then it tries to send the E but the Pi never acknowledges that it receives it. this is backed up by 1) the debug menu on the scope shows that it tries to send both T and E, and then stops; and 2) the scope otherwise works fine with a USB GPIB adapter.this discussion is kinda pointless for now because i reinstalled the OS on the Pi and now nothing works :c
>>2812851the gpio_request_one() is failing on the first call. it was at least partially working before reinstalling the OS, but its fucked now. its also concerning that the function is apparently deprecated. i dont think any other processes are using any GPIO pins. not sure what to do.
>>2812751no. what you have is chink shit clones of "bluepill and stlink".
>>2812876ok i also have a chinkshit clone of arduino and it works fine, why wouldnt this
>>2812883because its much easier to clone. expecting any chink shit to work properly its just retarded. get some legit devices, verify your shit works, then roll the dice with chang
>>2812861What’s errno?
>>2812911iunno, errno isnt working in the kernel module for some reason.
>>2812876iirc stlink is an open source design so anyone can make and sell thempretty good idea for making your products more accessible, especially considering the low price of the stlinkatmel can eat my ass im never buying an atmel ice or dragon>>2812914well i’unno either mate
I thought i would use the day productively today and progress with the ARM Cortex courseI hit the point where I need a simulator now. i've spend the ENTIRE day trying to make the simulator work but it tries to build something and then fails.i have no idea what to do.i fucking H A T E packages that you have to build yourself. Today is a wasted day thanks to those delays.I'm going to jerk off to some porn, and then i'm going to the gym. fuck this shit.
>>2813014apt install qemu-system-armGetting it to work requires some fiddling if you're new to this.I rarely need an emulator. I run everything local (on x86) or on a dev board. the only time when an emulator makes sense to me is when writing asm.
I'm looking to make a battery powered device that can be controlled with an RF remote controller inside an apartment. The device will be idle for 99% of the time and during periods of activity I don't expect it to consume more than some tens of mA, and I want the battery to last as long as possible, preferably months to a year.So, what I need is a digital radio protocol that can remain at a very low power consumption idle while still being able to wake up on radio activity, my understanding is that WiFi, BLE etc. will not work because they need to remain connected in a high power state to hear anything at all, does what I'm looking for even exist in a neat module or will I have to resort to a separate RX detector and all that?
>>2813029>I don't expect it to consume more than some tens of mA.thats a lot, low-power MCUs idle current is typically in the nanoamps. the IR receiver in pic rel has a typical supply current of 350uA. they probably make low-power IR receivers too.
>>2813092oh i can read lol. well you got your answer.
>>2813093fuck, cant type either, apparently.
>>2813029https://forum.allaboutcircuits.com/threads/low-power-ir-detection-circuit.115744/page-2#post-911606guy on this forum reduced the IR detector current by a factor of 10 down to 35uA by cycling it at 7%.
>>2813092‘FT’ is the acronym for ‘Five volt Tolerant’ now?That’s a disgraceful example of zoomerese.Data sheets an app notes are going down hill.> STMAs expected, about as much street cred as batteroo.
>>2813092Thanks, I was looking at RF remote controls so it's not so sensitive about directivity but those do seem like really good numbers
>>2813029Receiving only? Some sort of 433 MHz bullshit like zigbee or whatever would probably be my go-to, so long as the protocol does t require duplex. Ideally built into an MCU like an NRF something. LoRa is great for low power transmission but that’s not a requirement unless you want to really minimise the remote’s power consumption too. Even then it’s probably overkill since normal RF remotes last years on a 2032, and the NRF-based LoRa receivers are really expensive.Also check out cnlohr’s latest video.
>>2812541QNX is somewhat popular, but its for chips with Raspberry Pi power, not microcontrollers.
>>2810945There's the Milk-V, a RISC-V board with an Arduino core on the sidehttps://www.youtube.com/watch?v=SeExddxWdNs