Show Posts
Pages: [1] 2 3 ... 87
1  Using Arduino / Project Guidance / Re: G Code on Arduino? on: August 28, 2014, 02:48:37 pm
Sure. Use the Progmem feature. This allows you to store an array in the 32K Flash/Programstore. Only hassle is that you need to write it as part of your program as one long
prog_uchar Motion[] PROGMEM  = {"G1 X10 Y10;G1 Z10 E10;G1 X5 Y5 Z5 E5; ....
(here I've used the ";" as the newlinecharacter.

You can split your program into several files, so one file only holds this progmem defenition.

At this time it may occur to you that you are using 10 bytes to store two ints. So I would throw away all the Gcode interpretation and just store the XYZE values in a list of ints. Yes, the Gcode allows for floats, but you can just scale it up by (say) 10 and then only store it in inst which are tenths of millimitere. (int limits you to +/- 32000). Or you can define your own "language" and really compress/save bytes.

Then you can go sophisticated and transfer from serial port to EEprom (which though only holds 1K) so you do not need to reprogarm. Or go the whole hog and implement you falshprogramming - but that is far beyond my skills, too
2  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: August 28, 2014, 02:34:33 pm
kinda solved it, when i figured only writeMicroseconds can override the middle position after attach,
slowmove cant and write probably cant too...
so i can store the position of the servos after each move to eeprom and write it back in void setup before attaching the servos.
That would have been my suggestion, too. Note that the eeprom is not infinitly rewritable ("The EEPROM has an endurance of at least 100,000 write/erase cycles" in the spec), so add in a some "filtering" so you only store when there has been a great enough move from previous stored value if you do this many times a second. (one million seconds is 11+ days)
3  International / Scandinavia / Re: Vibrationsmatare med ljusbarriär. on: August 28, 2014, 02:16:28 pm
Ska jag sätta "delay" någon annan stans?

Nej och nej nej nej - låt bli att använda delay.


Din program logik skal vara at den nolställer en Timer varhe gång den bryts og stänger mataren när timeren er 4000 större en millis.

Nämde jag att du inte skal använda delay() ?
4  Using Arduino / Project Guidance / Re: LED controller zones on: August 14, 2014, 01:28:57 pm
You can use two wires to simulate a button. Join them - button pushed. Seperate them - button un-pushed. smiley-cool

can you run a loop to send signals to an LED strip while at the same time selecting which program
Yes of course you can do that. There is almost no limit what you can do with the software logic as long as the timing is not too critical or short. Anything that involve blinking lights, buttons pushed by humans is dooable. Look at the avreage 3D printer. It reads an SD card with instructions, pulses the steppers, monitors the temperature, end stop switches and if not using a SD, monitors the ASCII input for the next command. (Yes, I wrote such a  program from scratch.)

Somewhere in here i worte a similar example some time ago. (damn the limited search facility). This item is not what I am thinkimg of, but it might help you see the way forward.
5  Using Arduino / Project Guidance / Re: LED controller zones on: August 13, 2014, 04:04:49 pm
Yeah, that was what I was afraid of.
How to change a variable after it's been defined
Of course, that is really Programming and not a Project Guidance?

int a = 7 ;  // defines and gives the variable an initial value (before setup or loop runs)

inside setup(), loop() or your own functions:
  a = 13 ;  // "change a variable after it's been defined"

Now if the above was too simple, then appologies for misunderstanding your question, and carry on with the text below. If that was revealing, then you first need to understand "basic programming" way before you cut-n-paste more code pieces or "combine" them.

The problem you pose is the same whether we are talking about "zones" (whatever that was, did not understand your explanation) or just a simple LED. Likewise buttons or "LCD as a Pushbutton". I guess you are using a "standard" LCD/pushbutton unit with accompaning library.

Suggestion to you: Get your Arduino, hook up a few LEDs (each with a resistor) and a few buttons (connecting the Arduino pin to GND when pressed - set the pin to INPUT_PULLUP). Now you have an enviroment to exercise your programming skills and when that works you can wire up your Zones and LCD and all that. Create projects in small steps.

The first programming exercise should be a Push-On Push-Off functionality. (there is a minor challenge that you need to debounce the button. The simpleminded way is with delay, the correct way is with a timer. The former will work "well enough" for what you have explained, but will bite you if/when the project includes more stuff). 
6  Using Arduino / Project Guidance / Re: Controlling ESCs on: August 13, 2014, 12:50:27 pm
If you did not get some paper or documentation with your stuff, then you can guess, guess, guess ... or you can use use google with the type number, type name and anything else on the label. Unless there is somelese here with those exact same controllers that knows.
7  Using Arduino / Project Guidance / Re: LED controller zones on: August 13, 2014, 12:43:23 pm
What code have you written so far (you write "the program that is currently running")? Or what example are you wondering how to modify?
Show the code, show the code....
8  Community / Exhibition / Gallery / Re: Bathroom fan control on: August 06, 2014, 01:17:06 pm
The thing with millis(), long or not long, rollover problem is that after 52days continously, it will roll over.
That will render your sketch useless for 52days.

The way to deal with it is that your millis can can never be less than your previous stored millis.

If that happens you just make them equal.
Rubbish. smiley-yell

If you use unsigned variables and do the subtraction the "rollover" problem does NOT EXIST.

Here is a post where I have a longer explanation.  ->

And back to the posters next question (inspired by janost's FUD)
Is there any way of "speeding up" millis to test the rollover?
You can use unsigned integer for all "timer variables". Use word(millis() ) to get current value. Now you get the rollover every 65.536 seconds. So you test program should have timers at 10 seconds duration or so. (Otherwise you may fall into the trap and confusion of timers "auto retriggering" as described in my longer explanation above)
9  Using Arduino / Programming Questions / Re: Operator bitshift on: July 31, 2014, 08:01:12 am
"all the RAM" ? No not really.

"A << 5" is an expression. It returns whatever A contained leftshifted 5 times (which is (almost) the same as multiplying by 32).

If A is a byte and it contains B01000000 then the result will be 0, as the "1" fell off the end.
If A is an int and thus contains B0000000001000000 then the result will be 0000010000000000
If A is an array, A << 5 is illegal (it may do an address expression, but it will NOT move all elements of A) but A[1] <<5 makes sense.

Either way, "A" does not change, it is just an expression, you need to put the result somewhere:
B = A <<5 ;
A = A << 5 ;
10  Community / Exhibition / Gallery / Re: Bathroom fan control on: July 31, 2014, 07:49:11 am
"timer" variables should be
unsigned long previousMillis = 0;        // will store last time LED was updated
Then the magic works - there is no problem with "overflow" - you have written the code right
if(millis() - previousMillisLed > interval) {
11  Using Arduino / Programming Questions / Re: int to byte conversion on: July 28, 2014, 11:59:21 am
(Crossroad asking a question - must try and answer !)

Cant think of anything faster. With a little carefull programming not take much more then 20-50 instructions... or about 20 uS meaning it will take less than a thousandth of your 3 ms time window.

If for some reason yu are stuck by extreme time problem, you could rewire your output circuitry so the ints map better, ie the redunant bits are ignored (I presume we're talking a set of shift registers here)
12  International / Scandinavia / Re: Power supply - mega on: July 27, 2014, 03:04:29 pm
Ja, og skillnaden er at der en diode i BarrelConnectoren (om du nu har en strömforsyningen som har - i mitten). Men det har VIN inte så akta akta. (Den har det inte før at man kan ta ut like bra som sätta in ström på Vin).
13  Using Arduino / Project Guidance / Re: G Code on Arduino? on: July 24, 2014, 03:23:49 pm
I agree with both of you, and maybe not.

Gcode in the 3D printer (or CNC etc) masks the interal workings of the device (turns/mm stuff, postive end stop), yes.

However most slicers need to know much of the printer anyhow in order to generate a good Gcode. F.eks. "retract head slightly and the filament when moving to another section" Here the slicer generates several lines of Gcode to do something that should be internal. Also the slicer needs to know which dialect of Gcode the printer can cope with. (In fact I know of at least two equally used modes of comments - one where the line starting with # is a comment and one where enclosing text in round brackts is a comment. So much for Gcode standard....)

On the other hand when spooling a print of an SD card, you can adjust some running parameters (like the speed) on the fly, as these are below the Gcode layer. Well, may be that could be done with a lower-level software, too.

I notice that programs like Mach3 which control the steppers directly also take Gcode as the input from some other program.

But the biggest motivator is probably TRADITION.  "because that is how we always have done it".
14  Using Arduino / Project Guidance / Re: 3x3x3 LED Cube Malfunction on: July 24, 2014, 02:58:17 pm
( @spycatcher2k There is an #include - seem OK to me )

WireEverywhere - You wrote
I tried to upload the code below but there was something wrong with it
What - it displayed the Pong game instead? Or did the upload fail (no program uploaded at all)

In other words - what was not working / displaying as you expected? You must state What you hoped would happen (and why, ie. what did you do) and what actually happened.

You also write
There are four LEDs in the bottom row that are very bright compared to the other led's
Well, could be your wiring, could be a bad transistor, could be the program. Now you did include the code, but please also include the cube library you are using, so we who are trying to help do not first have to find it (and possibly find a differnet version)

Which brings me back to the first question - apperently some LEDs are lit up, but is it displaying some apttern or is that just a static display ... or an artifact from a previous uploaded unrelated program
15  International / Scandinavia / Re: Power supply - mega on: July 24, 2014, 12:12:16 pm
Sæt 7V (eller op til 12V) på strømstikket.
Brug en 5V forsyning (eller lidt mindre er også OK) og sæt det på 5V pinden.
Der er et kredslop som sørger for at den skifter hvor den tager strøm fra når du hiver USB pinden ind/ud.
Pages: [1] 2 3 ... 87