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
echinopsis
Apr 13, 2004

by Fluffdaddy

Sagebrush posted:

how did you get into bitwise math without getting past use of delay()?

it was essential for what i was trying to do (passing arrays around in c fucks me up) so i copied and pasted it from a website! i understand it kind of but not enough to do it myself. i intend to work it out



quote:

also, for tuning the whiteness of rgb leds i wrote a little processing app that sends serial commands to raise or lower the r/g/b values and then prints out the current settings. just press butan until you get the right color and then write down the values. writing processing apps is super easy but if you don't know how you could do a similar thing with, like, a button to toggle through a state machine and a potentiometer to dial up or down, or something.

im all down with sending serial but recieving it i just dont even know the first thing. i have thought of this conceptually but im happy recompiling trial and wrror


the thing is that the colour is also relative to what came before it. if i let it go 255 for all colours it looks green but only because its been preceded by red and the green is the last colour to clamp when i crank the gain. my system and the settings so far give a convincing set of colours kinda

Adbot
ADBOT LOVES YOU

Doc Block
Apr 15, 2003
Fun Shoe

echinopsis posted:

how bad is it for me to use floats?

the atmega328 microcontroller that your arduino uses can't do floating point math in hardware, there's no FPU or anything. so it has to be done in software, which means it's not only a lot slower but also requires the inclusion of a couple kilobytes worth of floating point math routines.

of course, the arduino libraries use floating point in a few places so you're probably already indirectly including the FP math stuff.

~Coxy
Dec 9, 2003

R.I.P. Inter-OS Sass - b.2000AD d.2003AD

echinopsis posted:

the thing is that the colour is also relative to what came before it. if i let it go 255 for all colours it looks green but only because its been preceded by red and the green is the last colour to clamp when i crank the gain. my system and the settings so far give a convincing set of colours kinda

that's a good point I ran into the same issue with the philips Hue LED light bulb

echinopsis
Apr 13, 2004

by Fluffdaddy

Doc Block posted:

the atmega328 microcontroller that your arduino uses can't do floating point math in hardware, there's no FPU or anything. so it has to be done in software, which means it's not only a lot slower but also requires the inclusion of a couple kilobytes worth of floating point math routines.

of course, the arduino libraries use floating point in a few places so you're probably already indirectly including the FP math stuff.

how else can I use decimal fractions? or just take the performance hit given actually how few of them need to be done overall

echinopsis
Apr 13, 2004

by Fluffdaddy
this thing will basically have "nighttime" which is a nightlight and is very dim and sorta shadows moving effect (haven't made this yet) and the sunrise progression which will happen at a particular time. i need to work out a way to move from one to the other.. actually writing this right now I just worked it out

Sagebrush
Feb 26, 2012

echinopsis posted:

how else can I use decimal fractions? or just take the performance hit given actually how few of them need to be done overall

work with big integers and scale them afterwards

eg: you need 2 decimal places in a scale of 0 to 100. well just do all your math on ints from a range of 0 to 10000 and have the rest of your code handle it accordingly

echinopsis
Apr 13, 2004

by Fluffdaddy
that had occurred to me. if i run into performance issues i'll do that. ive fiddled it around to run without a delay so i guess i'll only run into issues if my calculations are taking longer than my millisecond interval



:smugmrgw: i borrowed your code from a few pages back regarding timging


and i think i understand those bitwise operators now. not enough to do it flawlessly or make sure i was using the correct end of the HEX value but i thinik i get it. its a good way to store multiple variables in one number. are they fast operations?

Luigi Thirty
Apr 30, 2006

Emergency confection port.

the atmega328 also doesn't have a hardware divide unit right

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp

echinopsis posted:

its a good way to store multiple variables in one number. are they fast operations?

the port registers are the pro way to twiddle outputs and read inputs:

http://www.arduino.cc/en/Reference/PortManipulation

for a speed comparison, if you use the arduino digitalwrite() as fast as you can, you can twiddle a port on an arduino at about 15 khz. If you do it with the port registers, you can do it at over 1 MHz.

Wild EEPROM
Jul 29, 2011


oh, my, god. Becky, look at her bitrate.
box update 2: I built a bigger, stronger (and much heavier) box



echinopsis
Apr 13, 2004

by Fluffdaddy

Jonny 290 posted:

the port registers are the pro way to twiddle outputs and read inputs:

http://www.arduino.cc/en/Reference/PortManipulation

for a speed comparison, if you use the arduino digitalwrite() as fast as you can, you can twiddle a port on an arduino at about 15 khz. If you do it with the port registers, you can do it at over 1 MHz.

i guess that means yes... :q:

Sagebrush
Feb 26, 2012

Luigi Thirty posted:

the atmega328 also doesn't have a hardware divide unit right

hmm. that may be the case. well, you can always bit-shift and add

Sagebrush
Feb 26, 2012

Wild EEPROM posted:

box update 2: I built a bigger, stronger (and much heavier) box





i like these unexplained posts about boxes. you're just a dude who makes boxes. like that guy on youtube who just smokes pipes and wears different hats. it's just the thing you do. keep on keepin on

Bloody
Mar 3, 2013

echinopsis posted:

that had occurred to me. if i run into performance issues i'll do that. ive fiddled it around to run without a delay so i guess i'll only run into issues if my calculations are taking longer than my millisecond interval



:smugmrgw: i borrowed your code from a few pages back regarding timging


and i think i understand those bitwise operators now. not enough to do it flawlessly or make sure i was using the correct end of the HEX value but i thinik i get it. its a good way to store multiple variables in one number. are they fast operations?

since you're masking at byte boundaries, yes*

comedy factors where no, it will be slow as balls:
your microcontroller's architecture does not have a barrel shifter (lookin @ u msp430) -> all shifts get turned into piles of rotates. shifting by a variable? enjoy your rotates and branches!
you're compiling with optimizations turned off -> byte-boundary masks will just get turned into byte reads from some larger sea of memory (in this case, a uint32 or w/e). this only happens at some optimization levels! this penalty doesn't matter much unless you also dont have a shifter in which case lmao @ you

i think the atmega has a shifter so w/e

although i don't think there's a defensible reason to not either do it with a 4-parameter function or with structs!

Bloody
Mar 3, 2013

also the idiomatic c foreverloop is for(;;) {...} not that fuckin do{...} while(2>1) poo poo you got smdh

syscall girl
Nov 7, 2009

by FactsAreUseless
Fun Shoe

Bloody posted:

also the idiomatic c foreverloop is for(;;) {...} not that fuckin do{...} while(2>1) poo poo you got smdh

lol check disable smilies smdh

Doc Block
Apr 15, 2003
Fun Shoe

Wild EEPROM posted:

box update 2: I built a bigger, stronger (and much heavier) box





where the gently caress did you get pieces of plywood that big that aren't warped to hell?

also, i don't think i would be good at making wooden boxes since i can't seem to ever cut a perfect 90 degree angle, no matter how much effort i put into it.

theadder
Dec 30, 2011


syscall girl posted:

lol check disable smilies smdh

same

Panty Saluter
Jan 17, 2004

Making learning fun!
i made an fm antenna today

there really is gently caress all to listen to but its still pulling from a station about 80 miles away so im impressed. it's just two dowels with a single 22 awg conductor running arounc the periphery and attached to a balun. its really simple compared to what yall are doin but im kinda proud of it nonetheless

Only registered members can see post attachments!

echinopsis
Apr 13, 2004

by Fluffdaddy

Bloody posted:

also the idiomatic c foreverloop is for(;;) {...} not that fuckin do{...} while(2>1) poo poo you got smdh

hahaha ok. especially given I'm doing it in the main loop designed to be executed over and over for infinity


still it's a great example of my inguinuoty

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
I like while (1) {...} better

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

echinopsis posted:

koiwoi unguinuoity

Sagebrush
Feb 26, 2012

Symbolic Butt posted:

I like while (1) {...} better

me too. it's the pro way

movax
Aug 30, 2008

Bloody posted:

since you're masking at byte boundaries, yes*

comedy factors where no, it will be slow as balls:
your microcontroller's architecture does not have a barrel shifter (lookin @ u msp430) -> all shifts get turned into piles of rotates. shifting by a variable? enjoy your rotates and branches!
you're compiling with optimizations turned off -> byte-boundary masks will just get turned into byte reads from some larger sea of memory (in this case, a uint32 or w/e). this only happens at some optimization levels! this penalty doesn't matter much unless you also dont have a shifter in which case lmao @ you

i think the atmega has a shifter so w/e

although i don't think there's a defensible reason to not either do it with a 4-parameter function or with structs!

i hate the msp430 so much

why can't anyone else make mcus with fram

Luigi Thirty
Apr 30, 2006

Emergency confection port.

i don't think microcontrollers have needed oil filters since 1920 tim

Base Emitter
Apr 1, 2012

?

movax posted:

i hate the msp430 so much

why can't anyone else make mcus with fram

weren't there fram pics?

Sagebrush
Feb 26, 2012

i have a number of msp430s because several years ago ti was giving away those launchpad boards for $4.30 and they each came with a couple of spare chips and i was like "drat! this is so much cheaper than an arduino, or even a discrete mega328!" so i bought a couple planning to use them for small projects.

then i discovered the attiny.

echinopsis
Apr 13, 2004

by Fluffdaddy
https://www.adafruit.com/products/1655

the individual neopixels, not mounted to anything. are they surface mounted? is that something easy to achieve wth amateur skills

Woolwich Bagnet
Apr 27, 2003



echinopsis posted:

https://www.adafruit.com/products/1655

the individual neopixels, not mounted to anything. are they surface mounted? is that something easy to achieve wth amateur skills

they are, and you probably do not want to have to try and solder those. they are tiny tiny

Sagebrush
Feb 26, 2012

if you have a 5050 breakout board you can solder them on without too much trouble but then you might as well just buy the premounted ones they sell

dig around on the side -- for about twice the price of the individual chips they sell the neopixels potted in epoxy in a standard 5mm led housing w/ 4 wires. those are easy to work with

Captain Cool
Oct 23, 2004

This is a song about messin' with people who've been messin' with you

echinopsis posted:

https://www.adafruit.com/products/1655

the individual neopixels, not mounted to anything. are they surface mounted? is that something easy to achieve wth amateur skills
I haven't done surface mount in a long time but with a good iron you could probably learn to solder them. you would first need to design a pcb to put them on

also desoldering might require a heat gun which might destroy them

Base Emitter
Apr 1, 2012

?
there's hot air rework tools specifically made for soldering/desoldering surface mount that are sort of "precision heat guns". if you're going to invest money in doing surface mount stuff.

movax
Aug 30, 2008

Base Emitter posted:

weren't there fram pics?

i would be the happiest man alive if fram pics or fram arms existed

Wild EEPROM
Jul 29, 2011


oh, my, god. Becky, look at her bitrate.

Doc Block posted:

where the gently caress did you get pieces of plywood that big that aren't warped to hell?

also, i don't think i would be good at making wooden boxes since i can't seem to ever cut a perfect 90 degree angle, no matter how much effort i put into it.

The plywood I used was warped to hell, probably a good inch off from the edges to the middle, I just nailed and glued it in such a way that every piece holds every other piece straight.

I can't cut perfect 90 degree angles either, most people can't. What you want to do is get a table saw with a good fence.

echinopsis
Apr 13, 2004

by Fluffdaddy
code:
if (millis() > t+risedelay+delayinjection);
    {
    	//Serial.print(millis());
    	//Serial.print(" ");
    	//Serial.println(t+risedelay+delayinjection);
    	t=millis();
    	 	 	
    	
    	delayinjection=0;
    	gain=gain+iterator;

    	if (gain<0)
    	{
    		iterator = iterator *-1;
			//risedelay = risedelay*stallfactor;
			delayinjection=500;
		}
		else if (gain>maxgain)
		{
			iterator = iterator *-1;	
		}
		


	}
this seems to be escuting over and over and over and not at the interval i want. i cant fuckin work it out at all

Corla Plankun
May 8, 2007

improve the lives of everyone
make sure all of those variables are the same type

for an arduino i think they should all be unsigned long

i have made that mistake before.

Bloody
Mar 3, 2013

movax posted:

i hate the msp430 so much

why can't anyone else make mcus with fram

why do you need fram

movax
Aug 30, 2008

Bloody posted:

why do you need fram

fram's more resilient for certain environments

Luigi Thirty
Apr 30, 2006

Emergency confection port.

got the measurements of my 7-segment wrong, wasted $35 on 3 boards that won't work

Adbot
ADBOT LOVES YOU

Bloody
Mar 3, 2013

movax posted:

fram's more resilient for certain environments

what like rad-hard or high-temp or?

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