Date: Thu, 21 Jun 2012 08:04:54 +0200 (CEST) From: Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl> To: Modulok <modulok@gmail.com> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: OT: Robotics or embedded or hardware programming... what is this called? Message-ID: <alpine.BSF.2.00.1206210755110.2867@wojtek.tensor.gdynia.pl> In-Reply-To: <CAN2%2BEpZNhPZLGqB1%2BqEG-X8BjAVzrW6ZR6FnLsF=H2oEGVtm4A@mail.gmail.com> References: <CAN2%2BEpZNhPZLGqB1%2BqEG-X8BjAVzrW6ZR6FnLsF=H2oEGVtm4A@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> I want to get started programming for hardware. Motors, sensors, actuators, etc. > I have a programming background, (python, PHP, C++) but no experience with code > that drives hardware. (Motors, sensors, etc.) add "--" to your language list so first 2 would disappear and third will become C. > I *don't* want closed-source "kit robots" where the point is to build the robot > the book and thats it. I also don't want ladder logic-based PMC's. Some kind of > micro-controller that runs a *nix flavor (or a BSD flavor!) would be great! (If Why do you want something like microcontroller to run any OS? > What do you call this? Embedded programming? Generic hardware programming? running unix on microcontroller-style hardware is what i call nonsense. Writing your program that runs from first executed instruction is what i call normal programming of such devices. The proper way is to 1) buy a microcontrooler chip, make your hardware using it, possibly buy already made boards. microcontrollers are <1$, some more capable 32-bit ones (ARM compatible usually, some are MIPS) for 2-3$. 2) throw away all included libraries because they are mostly mess. prepare something that can be used as crt0.s Better write it yourself in assembly. shouldn't be larger than 5 instructions anyway, a bit more if ARM interrupt vectors are needed to be filled. Some assembly knowledge is very useful, in spite of writing most in C. 3) read documentation. All embedded devices (like A/D converters, PWM generators etc.) are described. With 32-bit micros start from "memory MAP" chapter and then device description. You will just find out at what address your peripheral is accessible. 4) lets say for example that 32 GPIO pins are accessible at address 0x40001000 for setting ports, 0x40002000 for resetting ports, 0x40003000 for reading out value, and 0x40004000 for setting direction (input/output). #define GPIO0_SET ((int*)0x40001000) #define GPIO0_RESET ((int*)0x40002000) #define GPIO0_READ ((int*)0x40003000) #define GPIO0_DIR ((int*)0x40004000) 5) use it in your program. *GPIO0_DIR=0xFFFFFFFF; //sets all pins to output *GPIO0_SET=0xAAAAAAAA; //sets every other pin to 1 *GPIO0_RESET=0x55555555; //set the rest to 0 if you have questions send it privately. microcontrollers are wrong place for unix system and it's overcomplexity relatively to the task.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1206210755110.2867>