Notifications
Clear all

ask for help  

  RSS

gekopmac
(@gekopmac)
New Member
Joined: 3 months ago
Posts: 2
2020-05-06 7:58 pm  

Hello all,
I am arguing with MAX7219 LED Microcontroller 4 In 1 Display With 5 Pin Line.

The text is not good or is upside down. I am a beginner and am looking for a sketch which module can test for module which one is wrong, have read somewhere that sometimes it is possible that a module is mounted incorrectly.

for example:
matrix 1 led 1 to 64, matrix 2 1-64 etc to 4.

tried all the different sketches but I can't figure out which one is wrong or upside down.

Best regards
Henk de Sain


Quote
Topic Tags
gekopmac
(@gekopmac)
New Member
Joined: 3 months ago
Posts: 2
2020-05-09 9:39 pm  

<SOLVED>

you have to change the scetch and not the library.

all ok.

 

rgd

 


ReplyQuote
Runutral
(@runutral)
Active Member
Joined: 3 months ago
Posts: 13
2020-05-15 12:38 pm  

I am trying to use part of controlling  dc motors with L298N and arduino for my switching locomotive

To increase speed I use the for (i=0;i<256;i++) and analogWrite (PWM,i) and a delay(20)

to increase the speed from zero to a certain speed. However, the delay(20) is necessary to get a slow increasing speed, and works ok. Now I want the speed stay at that speed until I find a stop signal ( reed relay and magnet, and than decrease speed to zero. However due to the delay(20) the increased speed stops after a few seconds and than start all over again. How can I get the increase of the speed and than stay at that speed indefinitely until new command is given.


ReplyQuote
triform
(@triform)
Reputable Member
Joined: 11 months ago
Posts: 296
2020-05-15 3:45 pm  

@runutral

Once you get to the speed you want, drop out of the loop or end it.  The last analogWrite value you write will be used.


ReplyQuote
starnovice
(@starnovice)
Estimable Member
Joined: 12 months ago
Posts: 159
2020-05-15 4:47 pm  

@runutral Put the delay before the analogWrite

Pat Wicker (Portland, OR, USA)


ReplyQuote
byron
(@byron)
Reputable Member
Joined: 12 months ago
Posts: 297
2020-05-15 4:54 pm  

@runutral

I've recently been dabbling in a small 'run a motor' program and as triform indicates the speed up the motor bit is usually over and done with once the motor is running at the desired speed and your program should be ready for some other command.  

In my program I have a function where I pass the desired speed in as a function parameter. (e.g. void go(int ChgSpeed) {....} ). In your case, in your function, you could replace your 256 number in your for loop with a variable.  (for (i=0;i<ChgSpeed;i++) Outside of the function the variable would be assigned a number, e.g. 256 and this is passed to the function.   The function then ramps up your motor and when done will return control the main program ready for the next command.  The next command could be to stop the motor so the value of 0 is assigned to the variable and the function is called again.   Note that in the function one simple for loop will not cater for both ramping up a ramping down the motor, but throw in a few if statements or whatever (lots of ways to code this) and it should work a treat.   

A final though for you is what happens if a stop is required when your function is ramping up to speed. If this is a possibility then you will need to check for something (a global variable setting perhaps) at each point in your loop.  In your example this would be after each iteration of your for loop.  The minimum time your loop could check this is after every delay(20) and if that too long a time and you want an immediate stop there are other ways to signal an immediate stop if this is necessary.

I hope this has given you some food for thought 😀 

This post was modified 2 weeks ago by byron

ReplyQuote
Runutral
(@runutral)
Active Member
Joined: 3 months ago
Posts: 13
2020-05-15 7:22 pm  

@byron

Thanks for your answer. The stop will not be called before the motor is up to speed. The speed will be set to a low value. Switching loco do not move fast for real. I am going to try a function as you suggested.

I am looking for the possibility to just run the loop for just one cycle, and have the motor stay on that set speed for starters. The stop will be the next fase. After that is the inclusion of an remote control. An other arduino will have the real program that gives the start of the loco, the loco stops when finding a magnet with reed relay. The program tells where the loco goes and set switchces, as well as uncouplers, The program will direct the loco to pick up and deliver cars.


ReplyQuote
byron
(@byron)
Reputable Member
Joined: 12 months ago
Posts: 297
2020-05-15 8:15 pm  

@runutral

Be sure to run the function outside of the void loop() {} or it will continuously cycle your code.  Run it from setup() or even maybe just put your code in setup.  And note what @starnovice said above, you dont want a final delay after you've reached top speed, so put the delay first.


ReplyQuote