| Arduino Forum ::  Members :: MarkT
 Show Posts Pages: [1] 2 3 ... 840
 1 Products / Arduino Due / Re: attachInterrupt get interrupted pin on: Today at 11:31:40 am C and C++ don't support closures, so there's no way to define functionsat runtime.  Its pretty clunky in fact.  And the macro system is horrible beyondreason.
 2 Using Arduino / Motors, Mechanics, and Power / Re: Suggestions to buy a battery for multicopter on: Today at 11:28:40 am That's why you have to give us all the details you have, not just a part number!!  We caninterpret the data, but you've got to make it accessible to our impatient collective gaze Go and read the sticky thread that says "read this before posting" or some such....
 3 Using Arduino / Motors, Mechanics, and Power / Re: Two 300RPM 12V DC motors connected to arduino motor shield r3 power supply on: Today at 11:26:16 am You have told us nothing about the motors that's useful other than they are 12V.We need to know the stall current rating, and preferably the full rated load current/powertoo.  Any information please, even a photo would help to see how big they are.If they are 12V why are you thinking of using 9V at all?Small 9V batteries cannot power motors or servos, they just cannot produceenough current, give up on the 9V battery notion completely!
 4 Using Arduino / Motors, Mechanics, and Power / Re: I need help with my 48v Brushless Motor Controller Circuit on: Today at 11:22:04 am Make Cboot (in nF) equal/greater to the total gate charge (in nC)Make the 12V decoupling capacitor at least 10 times Cboot.You want the voltage sage from the high-side drivers to be 10% or less as they switch, so Cboot should be 10x the gate _capacitance_, howeverthe gate capacitance isn't linear, its better to think of total gate chargedivided by gate voltage.Thus Cboot = 10 x Cgate = 10 x (Qgate / 10V) = QgateWe divide by 10V rather than 12V to allow for the voltage droopingand the voltage loss in the bootstrap diode.Do _not_ add a 10k gate-source resistor to the MOSFETs, this just drains theCboot way fast.  A 15V zener between gate and source for each MOSFET isa good precaution to protect gates from over-voltage.  Simple, cheap.
 5 Using Arduino / Motors, Mechanics, and Power / Re: Low Pass Filter Usage After Motor Driver Card? on: Today at 11:15:23 am The problem with just sensing the average voltage is that it doesn't tell you anythinguseful, since (in the normal regime) its just dependent on the PWM duty cycle.You could sense the current, but that's only a witness for the force (minus any friction),and is again strongly related to the duty cycle, and not the load.  And its worse thanthat, because the current controls the magnetomotive force (MMF), whereas the physicalforce depends on that _and_ the magnetic circuit's reluctance (ie the position ofthe plunger)  There is no guarantee of even a one-to-one mapping between MMF andphysical force (even before friction).If you want to sense the position you'll have to sense the position itself, it cannot beinferred from any electronic signal.
 6 Using Arduino / Motors, Mechanics, and Power / Re: Bipolar Stepper Motor : one step CW and one step CCW ??? on: Today at 11:07:39 am What motor?What controller?Links to datasheets or similar please, as you have been asked if you read the"read before posting" sticky thread.If you are hand-connecting a stepper to a controller you should realise thatdisconnecting a motor or winding from a powered-up motor controller isa good way of killing the controller dead.  Always power down before connectingor disconnecting motor wires from a stepper controller.If you want to understand how stepper motors work, there are manyresources out there for that.
 7 Using Arduino / Motors, Mechanics, and Power / Re: Suggestions to buy a battery for multicopter on: Today at 11:04:04 am Please don't make everyone google part numbers, include relevant links or theactual specs that matter.
 8 Using Arduino / Programming Questions / Re: Using If to trigger different functions on: Today at 11:02:10 am You at this thread - its about the same kind of problem:http://forum.arduino.cc/index.php?topic=268537.0In particular note the need to detect when the time now is _different_from the last time round loop() - that's when you should trigger actions,not every single time round the loop.The exact same issue applies to timed events using millis(), button presses,etc etc - you detect a change to trigger a response, not respond to a steadystate condition.If the reponse is idempotent, it doesn't matter, but when you need somenon-idempotent you have to pay attention to detecting transitions ratherthan states.Google "idempotent", its a great word.
 9 Using Arduino / Programming Questions / Re: Usage relay with step motor on: Today at 10:53:54 am For a full rotatation there are 12 lots of 30 degrees, so looping 12 times would belogical.If you code up the 30 degree move and triggering the camera and pausing 3 secondsinto a function with a clear name, that will make the code reabable.Code:void rotate_and_take_photo (){  stepper.setDirection(CW);  stepper.rotateDegrees(30);  stepper.runToPosition () ;  delay (100) ; // wait for motion to fully stop  trigger_camera() ;  delay (3000) ;  // allow time for the camera to focus and take picture}Now loop() just has to decide when to initiatiate the sequence, which would usea for-loop to iterate 12 times calling this function.Disclaimer - its not finished/complete code - you have to do the real work!
 10 Using Arduino / Programming Questions / Re: Interface TDA7439 with atmega 328p on: Today at 10:43:58 am You're doing some odd things, updating input / range / val variables in place -you should lose all those assignments and write some mapping functions:Lets look at setSnd:Code:void setSnd(int val, int range){  switch (range)    {    case 1:range = TDA7439_bass;break;    case 2:range = TDA7439_middle;break;    case 3:range = TDA7439_treble;break;    }   // uh-oh, no default case, have you considered that possibility?  switch (val)    {    case -7:val = 0;break;   // very verbose way to do this - there's a clear pattern    case -6:val = 1;break;   // to exploit here.    case -5:val = 2;break;    case -4:val = 3;break;    case -3:val = 4;break;    case -2:val = 5;break;    case -1:val = 6;break;    case 0 :val = 7;break;    case 1 :val = 14;break;    case 2 :val = 13;break;    case 3 :val = 12;break;    case 4 :val = 11;break;    case 5 :val = 10;break;    case 6 :val = 9;break;    case 7 :val = 8;break;    }   // uh-oh, no default case, have you considered that possibility?     writeWire(range, val);}(reformated a bit)Conceptually this function takes a range code, and a val code,and converts these to actual values for the writeWire call.Do the conversion in a function - this is exactly what a function does best:Code:int device_range (int range){  switch (range)    {    case 1: return TDA7439_bass;    case 2: return TDA7439_middle;    case 3: return TDA7439_treble;    default:  // so what about this case - perhaps we need to flag an error?      return range ;    }}// each function does one thing, much easier to maintainint device_val (int val){  if (val >= -7 && val <= 0)  // exploit the obvious pattern in the mapping    return val + 7 ;  if (val > 0 && val <= 7)    return 15 - val ;  // so what about other cases?  perhaps flag an error  return val ;}// Now setSnd is nice and simple, very clear.void setSnd (int val, int range){  writeWire (device_range (range), device_val (val) ;}
 11 Using Arduino / Programming Questions / Re: using multiple counters on 1 arduino on: Today at 10:24:00 am Oh yes, that's a howler.  You cannot compare char* style strings using ==,you have to call strcmp(). (+)You don't need strings to name states - do some research on enum, or #defineor const keyword.  You typically use named small numbers to identify thingsin code, not strings.If you want to print out the values then strings are appropriate(*), butinternally to the program that ends up being a clumsy and fragile wayof coding (experience will show you this, take it on trust for now!)(+) A char* string is represented as a pointer to char, ie the address ofsome chars that form the string.  The problem is many different copiesof the string could exist, with different addresses, so comparing addressesusing '==' could give false even though the same string contents areinvolved.The String class is available for a higher-level implementation ofstrings, and String objects can be compared by == because the classoverrides == for String objects.  String objects have more overheadsthan char* strings, and in particular heap-allocate, using more RAM.(*) You can index an array of string with the small integer value, forinstance.