Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Microcontrollers / Re: I need help in Programming Attiny85 via Arduino for LED turn off and On on: June 07, 2014, 06:33:05 pm
you set led to 0. this is PB0 so its on physical pin 5, yet u say your led is on pin3. I presume you mean physical pin3 which is obviously wrong, since that is PB4. what makes u think led =0 maps to pin 3, physical OR logical?

you really need to understand the mapping between arduino IDE pins and physical pins before trying something like this. arduino IDE is designed for arduinos. You are not using an arduino, you are using a bare 85. why should arduino code map to it? what if arduino IDE pin 6 mapped to physical pin 19...on an arduino wibble9999....why should it map to pin 19 on a tiny85?

might it be because the 85 only has 8 pins? do you see the problem now? arduino IDE pin numbers have nothing to do with the physical pin (leg) numbers on a chip.

every mcu is different. the IDE cleverly hides the underlying hardware from the user....arduino then print the logical pin number next to the physical pin of whatever chip your chosen arduino board uses. logical pin 13 might be physical pin 22 on one chip and 6 on another type...how do you reckon the
iDE copes eith the Due, which has a totally different family of processor with about a million legs on it? it could ben physical pin 255. ok im exaggerating but I hope you are starting to see how dirty your hands need to get if you insist on using a chip the IDE was never designed for.
2  Using Arduino / Microcontrollers / Re: I need help in Programming Attiny85 via Arduino for LED turn off and On on: June 07, 2014, 05:38:19 pm
Pin 7 = connected to the tx pin of my bluetooth
Pin 6 = connected to the rx pin of my bluetooth
pin 3 = connected to the LED pin of my bluetooth.

the include is define the pin 7 and 6 ( which is 2&1 for the 85) as the serial ports.#
and I was using the While(1) to let it constantly stay in the loop. i also tried a smaller board rate(4800) same behavior

But what am trying to do is to generate  a pwm signal to dim a LED and also turn on and off the LED, I have an application with a slider that send the signal from the app via the bluetooth from 0 - 255 to control the led from the 85. but it's not working for me.

you arent listening. pins in the arduino ide arent the same as physical pins. if you use 7 in arduino pinmode is IS NOT PHYSICAL PIN 7 ON THE CHIP, except by accident, im too lazy to check. I need to know what you have connected to THE PHYSICAL PINS and you still havent told me. the pins on the chip dont have defines, they are made of metal. they are numbered from 1 to 8 anticlockwise form the dotted top left corner. again I say, pin 1 is RESET and cannot be used for io without setting fuses.

if yoh cant answer simple questions I cant help yoh tell me what is connected to each and every pin OF THE CHIP. the chip, not your code, forget the code. it doesnt work. dont tell me about code, dont tell me about defines. dont tell me about arduino logical "digital pins" they are an invention of the arduino IDE and have nothing, but nothing to do with what is connected TO YOUR CHIP.

I cant make it any clearer. tell me what is wired to each and every leg of your chip, from 1 to 8. 4 has to be gnd and 8 has to be vcc. if there is anything on 1, it aint going to work...so now what is on chip legs 2,3,5,6 and 7? phew.
3  Using Arduino / General Electronics / Re: Problem reading random noise generator on: June 01, 2014, 02:56:11 pm
yes, I think, you are right, I only had 393 somimtried to use my limited knowledge to make at least something to work, even if far from perfect. i also couldnt find his valuemfor v+, hence my cheapmhack and recalculation to 5v. with your expert advice I may get the right op amp and try again. as i said before, I did get some sort of output, and at one sweet spot which I coild never replicate, my rudimentary processing sketch produced a pretty good looking distribution.

the one big thing I learned from this "failure" is that there is apparently random (at least to a novice) and then there is Random.

I also only have A level maths from 40years ago, so figuring out just how random my random was is beyond me. I am in awe of folk that can do maths or play the piano...

your excellent contribution has reignited my curiosity...I might well rebuild and report back, but dont hold your breath!



4  Using Arduino / General Electronics / Re: Problem reading random noise generator on: June 01, 2014, 01:17:49 pm
Wow, it's obvious that I don't have nearly as good of a grasp of this as I thought I did! I'm going to spend the morning reading all the responses and sources and come back when I can post an informed, coherent reply!
Thank you guys for your great, informative responses.
Avalanche noise is generally an order of magnitude lower for 5V and below sources (typically zeners') when compared to 12V+ sources, even when current is adjusted for.  Further the reverse bias transistor used in the OP example doesn't enter the breakdown zone until about 8-9V, though I have found a few examples of the 2N3904 (the transistor typically specified) that entered breakdown at lower voltages, the mean tends to be around 9V, with noise peaking near 12V.

The 'best' current for maximum noise varies with the device; however, the ones I have tested have generally been 5-50 uA.

Further, there have been several people who have tested a variety of such transistors, and the 2N3904 tend to produce the most noise.
I am limited to a voltage source of 9V for the final project, unfortunately, so I chose the 2N2222 as opposed to the 2N3904 because, even though it might not produced as much noise, it looks like it's easier to push into breakdown at lower voltages according to the example I cited in the OP. If I'm off base here, let me know.
I disagree. my original circuit was stolen from a 12v design. I dropped it to 5v, changed the NPN bias to get 2.5 ish midpoint and enough gain to exceed the upper and lower hystersis points of the 393. it didnt work...until I realised that the key point is the current through the noise source is quite critical. i guess most mfrs try to reruce noise and though zeners are inherently noisy there is a point on their curve where they are most noisy. we are talking nanocurrents here, any help you can get to boost the starting point is a bonus...I rebiased the zener to get the exact datasheet current point for peak noise and it burst into life....

albeit with the nyquist sample rate problem, so im not cel3brating yet, just my 2c that 5v circuits can be made noisy with a bit of care,a datasheet and a calculator
So you're using a Zener diode to generate avalanche noise as opposed to transistor breakdown? Does your circuit look something like this, getting the noise from the zener and then using the two transistors to amplify that?

yep, but with lm393 replacing 2nd xistor stage, op pulled up to give what I hoped was a random stream of digits, which I could count 8 off at a time to give me a series of random 8bit numbers, or so I naively thought....but hey im a,relative newbie to amps n volts, so I forgave myself. it seemd like a good idea. it taught me how to bias a transistor, at least...so it was worthwhile for my hobby needs. my main aim in all this is to learn learn learn not make millions designing a better microwidget.

the "zener" was a ZXRE4041 OR 1004 cant remember which and the peak noise current was something like 7 or 8 uA I think, which is bang in line with what the other far more knowledgeable posters have said. I shall drop out now in the presence of such greatness, my 2c has been spent! these blokes know whst they are on about, im just a nosey amateur.

5  Using Arduino / Programming Questions / Re: question for preprocessor gurus on: June 01, 2014, 12:55:13 pm
im not trying to "do" anything in the preprocessor, I justcwant to use it to its max to set up compile time constants so that my general purpose code has everything in place.

almost all of what it does is hw register specific and thus I want to make sure the correct registers for the mcu are in place prior to compile. an example...pseudocode, im on a tablet and correct syntax is a pain..

objective: register the interrupt n
strategy:
set bit in ctrl register to allow ints for the block that maps to pcint n
dtetermine mask register that maps pcint n
set bit in mask to allow int n

pseudocode for 328, tiny48, 2560 etc etc..any mcu using PCICR
PCICR |=_BV(PCIEx) // x depends on n, usually int.truncated n/8
PCMSKy |= _BV(n) // y dpends also on n, usually n%8
savedPort=PORTz // z depends on mcu and n

pseudocode for tiny24,44,2313 etc etc or any mcu using GIMSK
GIMSK |=_BV(PCIEx) // x depends on n, usually int.truncated n/8
PCMSKy |= _BV(n) // y dpends also on n, usually n%8 may well be different for this mcu from y above etc
savedPort=PORTz // different z per mcu of course and not same as above..

at its most abstract, I want
x=pcint2PCIEnumber(n)
y=pcint2PCKMSKnumber(n)
z=pcint2PORT(n)
%REG |= _BV(x) // or bv on PCIE%x, I dont mind
PCMSK%y ....
savedPort=PORT%z

etc where im using % as a conceptual tag for a replaced parameter

providing that my header defines the appropriate macros or functions for the mcu specific pcint2xxx routines and sets the %x y and z for the mcu, then that one piece of code will compile and work for whatever mcu is selected.

I know thats a very loose theoretcial explanation, but I hate typing on my tablet, and im sure you know where im coming from.

To me, that seems to be a proper, sensible and fairly common use of the preprocessor...its what some arduino cores do for things like digitalPinToPCICR, digitalPinToPCMSKBit etc..which do pretty much what I want to do, but NOT for arduino digital pins, for PCINT numbers. there are no corresponding GIMSK ....why would there be, arduino doesnt make any tiny45 or 2313 boards..but I do and I want a single library that will compile for all my targets. is it such a big ask...im 95% there already, I was just fitting in these lsst few edge cases when i had my idea about automatically pulling in mcuxxx.h files...

I think I need to take my php python hat off where everything is included at runtime and be tweaked within an inch of its life or even have parameters edited in and then eval'd...dont cringe!








6  Using Arduino / Microcontrollers / Re: I need help in Programming Attiny85 via Arduino for LED turn off and On on: June 01, 2014, 10:56:49 am
I don't get while (1)

Shouldn't it be just
Code:
void loop()
{
  char recvChar;  // Should this be in   void setup ()  ???
  if(blueToothSerial.available())
  {
    recvChar = blueToothSerial.read();
    if(recvChar == '1')
    {
      digitalWrite(led,HIGH); 
    }
    else   // meaning that   recvChar != '1'
    {
      digitalWrite(led,LOW);
    }
  }

Is ATtiny85 with its internal clock OK with 9600 baud?  (IOW, maybe try something slower?)
}

is right...the while is redundant since loop() already sits inside an infinite loop...which is kinda where it gets its name...but it doesnt actually hurt or break or change anything, its just inefficient/redundant/about 3 or 4 bytes fatter sketch.

i cant be bothered doing the 1mhz vs 9600 baud maths, but you may well have a point there, bearing in mind uno e.g. runs at 12mhz.
I still want to see the runtime wiring.
7  Using Arduino / Programming Questions / Re: My very first code, Looking for feedback... on: June 01, 2014, 10:49:22 am
Quote
"I dont know, but I been told...
'duino pins are made of gold
read your datasheet in full
then you wont get no more bull"

get down and give me 0x12!!!! 

Brings back memories of Air Force Basic Training at Lackland AFB, San Antonio , TX,  (1969)

glad you liked it. for me its Hendon Metropolitan Police concentration...sorry..."training" camp.
8  Using Arduino / General Electronics / Re: Problem reading random noise generator on: June 01, 2014, 10:43:28 am
Just to reinforce what Coding Badly pointed out, I made a circuit based on that type of design using 2n2222 and I found that a supply of 5V and 9V didn't work well. It needed at least 12V.


I disagree. my original circuit was stolen from a 12v design. I dropped it to 5v, changed the NPN bias to get 2.5 ish midpoint and enough gain to exceed the upper and lower hystersis points of the 393. it didnt work...until I realised that the key point is the current through the noise source is quite critical. i guess most mfrs try to reruce noise and though zeners are inherently noisy there is a point on their curve where they are most noisy. we are talking nanocurrents here, any help you can get to boost the starting point is a bonus...I rebiased the zener to get the exact datasheet current point for peak noise and it burst into life....

albeit with the nyquist sample rate problem, so im not cel3brating yet, just my 2c that 5v circuits can be made noisy with a bit of care,a datasheet and a calculator
9  Using Arduino / Programming Questions / Re: My very first code, Looking for feedback... on: June 01, 2014, 10:33:25 am
the chinese say "give a man a fish and you feed him for a day...teach him to fish and you feed him for life"

im also a SCUBA instructor and have a military / law enforcement background, and I tend to agree with your basic philosophy of teching fishermen rather than feeding them forma day with handouts.

in the nicest possible way, I can see a hint of the drill sergeant...but it aint such a bad thing, dont take it as a huge criticism, its an observation. as I said before, forumsget like this depend on guys like you.

"I dont know, but I been told...
'duino pins are made of gold
read your datasheet in full
then you wont get no more bull"

get down and give me 0x12!!!!

smiley




10  Using Arduino / Programming Questions / Re: question for preprocessor gurus on: June 01, 2014, 10:20:19 am
you guys are honing in on the kssue like bloodhounds. bills suggestion is kind of how io.h does it, and its what im grying to avoid as with 20.odd mcu im trying to handle it gets unwieldy fast.

also, bperrybap, thats exactly why im doing the work in atmel studio right now, to avoid any arduino complications. once the gremlins are out, I will then add an arduino.compatible library, so that newbies can say

#include "gpPCINT.H"

#define ENCA 10
#define ENCB 12

class myEncoder: public gpAbstractEncoder
{
...
}

myEncoder::onFwd(){ ...blink faster...}
myEncoder::onBwd(){ ...blink slower and go "ping"...}

myEncoder alps(ENCA,ENCB);

etc. thats the goal and as long as its an avr mcu target, you will get a nice clean debounced, interrupt driven button, encoder, heart monitor, mars rover "for free" with the nasty guts hidden.

its a beaytiful dream....thwarted only by a recalcitrant preprocessor. I will find another way...I know I can dot severalmhard ways, im just a bit of a penickety minimalist purist, seeking the most compact code, the occams razor...

sometimes I csn spend five times longer, finding the "quicker" way... I love it!
11  Using Arduino / Programming Questions / Re: A Special program on: June 01, 2014, 09:31:35 am
Yes, keeping the electrical away from water is a must. 120 volts and saltwater hurts like hell.
Pfttt! 120 volts is nothing, you want to try 250V.

Then again, maybe you don't.   smiley-grin smiley-grin

250v??? LUXURY!!!
Our dad used to hook us up to a pylon before breakfast....

You had it bloody easy! We had to work the treadmill generators 26 hours a day before our dad allowed us to be hooked up to a pylon...and NO breakfast...

Huh, we had no breakfast, hand full of gravel for dinner, and then had to work down t'mines for mobile phone ore the rest of the day.....

Tom........ smiley
right.

michael faraday used to use me to test his van der graaf generator by connecting it to my soft parts while making me stand in a bucket of salt water holding benjamin franklins kite during a thunderstorm for threepence every six weeks.

then he used to come home at night, cut us in half with a plasma cutter and dance about on our graves singing Kirchoff's laws.

tell that to the newbies today and they wont believe you...
12  Using Arduino / Programming Questions / Re: My very first code, Looking for feedback... on: June 01, 2014, 09:24:55 am
Then your more qualified to post a better example because I've only been programming since last october and I didn't write the example we're talking about.
maybe so, but much more lazy, too. you are doing a great job. its folk like you who make this forum work. grumpy old gits like me just add occasional spice.
13  Using Arduino / Programming Questions / Re: question for preprocessor gurus on: June 01, 2014, 09:21:38 am
sigh.

thanks guys

#define BRAIN 13
digitalWrite(BRAIN,LOW)

14  Using Arduino / Microcontrollers / Re: I need help in Programming Attiny85 via Arduino for LED turn off and On on: June 01, 2014, 09:14:34 am
also, what is that weird include meant to do?
15  Using Arduino / Microcontrollers / Re: I need help in Programming Attiny85 via Arduino for LED turn off and On on: June 01, 2014, 09:08:23 am
better still, since I know th 85 pinout and there are only 8, list me wht is connected to what when it is RUNNING

85pins
1 ?
2?
3?
4 GND
5?
6?
7?
8 5V

fill in the ? for me on your runtime setup (NOT during isp uploading), there are only six left...
Pages: [1] 2 3 ... 6